Class: Superstore::AttributeMethods::Definition
- Inherits:
-
Object
- Object
- Superstore::AttributeMethods::Definition
- Defined in:
- lib/superstore/attribute_methods/definition.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(model, name, type_class, options) ⇒ Definition
constructor
A new instance of Definition.
- #instantiate(value) ⇒ Object
Constructor Details
#initialize(model, name, type_class, options) ⇒ Definition
Returns a new instance of Definition.
5 6 7 8 |
# File 'lib/superstore/attribute_methods/definition.rb', line 5 def initialize(model, name, type_class, ) @name = name.to_s @type = type_class.new(model, ) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/superstore/attribute_methods/definition.rb', line 4 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
4 5 6 |
# File 'lib/superstore/attribute_methods/definition.rb', line 4 def type @type end |
Instance Method Details
#instantiate(value) ⇒ Object
10 11 12 13 14 |
# File 'lib/superstore/attribute_methods/definition.rb', line 10 def instantiate(value) return if value.nil? value.kind_of?(String) ? type.decode(value) : type.typecast(value) end |