Class: Superform::Field
Direct Known Subclasses
Instance Attribute Summary collapse
-
#dom ⇒ Object
readonly
Returns the value of attribute dom.
Attributes inherited from Node
Instance Method Summary collapse
- #assign(value) ⇒ Object (also: #value=)
-
#collection ⇒ Object
Wraps a field that’s an array of values with a bunch of fields that are indexed with the array’s index.
-
#initialize(key, parent:, object: nil, value: nil) ⇒ Field
constructor
A new instance of Field.
- #value ⇒ Object (also: #serialize)
Constructor Details
Instance Attribute Details
#dom ⇒ Object (readonly)
Returns the value of attribute dom.
197 198 199 |
# File 'lib/superform.rb', line 197 def dom @dom end |
Instance Method Details
#assign(value) ⇒ Object Also known as: value=
215 216 217 218 219 220 221 |
# File 'lib/superform.rb', line 215 def assign(value) if @object and @object.respond_to? "#{@key}=" @object.send "#{@key}=", value else @value = value end end |
#collection ⇒ Object
Wraps a field that’s an array of values with a bunch of fields that are indexed with the array’s index.
226 227 228 |
# File 'lib/superform.rb', line 226 def collection(&) @collection ||= FieldCollection.new(field: self, &) end |
#value ⇒ Object Also known as: serialize
206 207 208 209 210 211 212 |
# File 'lib/superform.rb', line 206 def value if @object and @object.respond_to? @key @object.send @key else @value end end |