Class: SimpleRecord::Attributes::Attribute
- Inherits:
-
Object
- Object
- SimpleRecord::Attributes::Attribute
- Defined in:
- lib/simple_record/attributes.rb
Overview
Holds information about an attribute
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #init_value(value) ⇒ Object
-
#initialize(type, options = nil) ⇒ Attribute
constructor
A new instance of Attribute.
Constructor Details
#initialize(type, options = nil) ⇒ Attribute
Returns a new instance of Attribute.
413 414 415 416 |
# File 'lib/simple_record/attributes.rb', line 413 def initialize(type, =nil) @type = type @options = end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
411 412 413 |
# File 'lib/simple_record/attributes.rb', line 411 def @options end |
#type ⇒ Object
Returns the value of attribute type.
411 412 413 |
# File 'lib/simple_record/attributes.rb', line 411 def type @type end |
Instance Method Details
#init_value(value) ⇒ Object
418 419 420 421 422 423 424 425 426 427 428 429 430 |
# File 'lib/simple_record/attributes.rb', line 418 def init_value(value) return value if value.nil? ret = value case self.type when :int if value.is_a? Array ret = value.collect { |x| x.to_i } else ret = value.to_i end end ret end |