Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require "active_support/core_ext/kernel/singleton_class"
- module EasySelectFields
- def easy_select_fields(a,options)
- type_method_name = "#{a}_types".to_sym
- array = options.each_with_index.map {|o,i| [o, i] }
- singleton_class.class_eval do
- define_method("#{a}_types") { array }
- end
- end
- end
- class Person
- extend EasySelectFields
- easy_select_fields "status", ["Interested", "Not Interested", "Available"]
- end
Add Comment
Please, Sign In to add comment