Module: Ohm::Typecast::ClassMethods
- Defined in:
- lib/ohm/contrib/typecast.rb
Instance Method Summary collapse
Instance Method Details
#attribute(name, type = Ohm::Types::String) ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/ohm/contrib/typecast.rb', line 144 def attribute(name, type = Ohm::Types::String) define_method(name) do value = read_local(name) value && type.new(value) end define_method(:"#{name}=") do |value| write_local(name, value && value.to_s) end attributes << name unless attributes.include?(name) end |