Module: Cymbalize::ClassMethods
- Defined in:
- lib/cymbalize.rb
Constant Summary collapse
- @@symbolized_options =
{}
Instance Method Summary collapse
- #options_for(attribute_name) ⇒ Object
- #symbolize(*attribute_names) ⇒ Object
- #symbolize_attribute(attribute_name, options) ⇒ Object
Instance Method Details
#options_for(attribute_name) ⇒ Object
46 47 48 |
# File 'lib/cymbalize.rb', line 46 def (attribute_name) @@symbolized_options[attribute_name] end |
#symbolize(*attribute_names) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/cymbalize.rb', line 10 def symbolize(*attribute_names) = attribute_names. attribute_names.each do |attribute_name| symbolize_attribute(attribute_name, ) end end |
#symbolize_attribute(attribute_name, options) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/cymbalize.rb', line 18 def symbolize_attribute(attribute_name, ) define_method attribute_name do read_symbolized_attribute(attribute_name) end if [:in].present? validates_inclusion_of attribute_name, :in => [:in], :allow_blank => !![:allow_blank] @@symbolized_options[attribute_name] = [:in] if !![:methods] [:in].each do |valid_type| define_method "#{valid_type}?" do read_symbolized_attribute(attribute_name) == valid_type end end end if !![:scopes] [:in].each do |valid_type| scope valid_type, where(attribute_name => valid_type) end end end end |