Class: Field::Base
- Inherits:
-
Object
- Object
- Field::Base
- Defined in:
- lib/field/base.rb
Instance Attribute Summary collapse
-
#fieldset ⇒ Object
readonly
Returns the value of attribute fieldset.
-
#form ⇒ Object
Returns the value of attribute form.
-
#name ⇒ Object
Returns the value of attribute name.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #add_attributes(klass, options) ⇒ Object
- #add_validations(klass, options) ⇒ Object
- #attribute ⇒ Object
- #form? ⇒ Boolean
-
#initialize(name, fieldset) ⇒ Base
constructor
A new instance of Base.
- #output ⇒ Object
Constructor Details
#initialize(name, fieldset) ⇒ Base
Returns a new instance of Base.
8 9 10 11 |
# File 'lib/field/base.rb', line 8 def initialize(name, fieldset) @name = name @fieldset = fieldset end |
Instance Attribute Details
#fieldset ⇒ Object (readonly)
Returns the value of attribute fieldset.
6 7 8 |
# File 'lib/field/base.rb', line 6 def fieldset @fieldset end |
#form ⇒ Object
Returns the value of attribute form.
4 5 6 |
# File 'lib/field/base.rb', line 4 def form @form end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/field/base.rb', line 3 def name @name end |
#value ⇒ Object
Returns the value of attribute value.
5 6 7 |
# File 'lib/field/base.rb', line 5 def value @value end |
Instance Method Details
#add_attributes(klass, options) ⇒ Object
13 14 15 |
# File 'lib/field/base.rb', line 13 def add_attributes(klass, ) klass.attribute name, self.attribute end |
#add_validations(klass, options) ⇒ Object
17 18 19 20 21 |
# File 'lib/field/base.rb', line 17 def add_validations(klass, ) if .any? klass.send(:validates, name, ) end end |
#attribute ⇒ Object
27 28 29 |
# File 'lib/field/base.rb', line 27 def attribute String end |
#form? ⇒ Boolean
23 24 25 |
# File 'lib/field/base.rb', line 23 def form? false end |
#output ⇒ Object
31 32 33 |
# File 'lib/field/base.rb', line 31 def output value end |