Module: TypeAttributes::ClassMethods
- Defined in:
- lib/type_attributes.rb
Instance Method Summary collapse
Instance Method Details
#type_attribute(name, cast_type) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/type_attributes.rb', line 18 def type_attribute(name, cast_type) name = name.to_sym cast_type = cast_type.to_sym @_generated_type_attribute_methods.class_eval " def \#{name}\n TypeAttributes::Type.cast_value(:\#{cast_type}, @\#{name})\n end\n\n def \#{name}=(decibels)\n @\#{name} = TypeAttributes::Type.cast_value(:\#{cast_type}, decibels)\n end\n METHOD\nend\n", __FILE__, __LINE__ + 1 |