Guest User

Untitled

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