Module: ActiveRecord::AttrSymbol::ClassMethods
- Defined in:
- lib/attr_symbol.rb
Instance Method Summary collapse
Instance Method Details
#attr_symbol(*attributes) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/attr_symbol.rb', line 9 def attr_symbol(*attributes) attributes.each do |attr| define_method(attr) do self[attr].try(:to_sym) end define_method("#{attr}=") do |value| self[attr] = value.blank? ? nil : value.try(:to_s) end end end |