Guest User

Untitled

a guest
May 21st, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. require "active_support/core_ext/kernel/singleton_class"
  2.  
  3. module EasySelectFields
  4. def easy_select_fields(a,options)
  5. type_method_name = "#{a}_types".to_sym
  6. array = options.each_with_index.map {|o,i| [o, i] }
  7.  
  8. singleton_class.class_eval do
  9. define_method("#{a}_types") { array }
  10. end
  11. end
  12. end
  13.  
  14. class Person
  15. extend EasySelectFields
  16. easy_select_fields "status", ["Interested", "Not Interested", "Available"]
  17. end
Add Comment
Please, Sign In to add comment