Class: SimpleFormObject::Attribute
- Inherits:
-
Object
- Object
- SimpleFormObject::Attribute
- Defined in:
- lib/simple_form_object.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#options ⇒ Object
Returns the value of attribute options.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #apply_default_to(form) ⇒ Object
- #fake_column ⇒ Object
-
#initialize(name, type = nil, options) ⇒ Attribute
constructor
A new instance of Attribute.
Constructor Details
#initialize(name, type = nil, options) ⇒ Attribute
Returns a new instance of Attribute.
89 90 91 92 93 94 95 |
# File 'lib/simple_form_object.rb', line 89 def initialize(name, type = nil, ) @name = name @type = type || :string = end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
97 98 99 |
# File 'lib/simple_form_object.rb', line 97 def name @name end |
#options ⇒ Object
Returns the value of attribute options.
97 98 99 |
# File 'lib/simple_form_object.rb', line 97 def end |
#type ⇒ Object
Returns the value of attribute type.
97 98 99 |
# File 'lib/simple_form_object.rb', line 97 def type @type end |
Instance Method Details
#apply_default_to(form) ⇒ Object
103 104 105 106 107 |
# File 'lib/simple_form_object.rb', line 103 def apply_default_to(form) if form.send(@name).nil? form.send("#{@name}=", default_value(form)) if @apply_default end end |
#fake_column ⇒ Object
99 100 101 |
# File 'lib/simple_form_object.rb', line 99 def fake_column self end |