Class: Odin::Forms::FormElement
- Inherits:
-
Object
- Object
- Odin::Forms::FormElement
- Defined in:
- lib/odin/forms/types.rb
Overview
A single form element. Backed by a property hash so optional attributes are present only when set in the source document.
Instance Attribute Summary collapse
-
#props ⇒ Object
readonly
Returns the value of attribute props.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #field? ⇒ Boolean
-
#initialize(props) ⇒ FormElement
constructor
A new instance of FormElement.
- #key?(key) ⇒ Boolean
- #name ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(props) ⇒ FormElement
Returns a new instance of FormElement.
41 42 43 |
# File 'lib/odin/forms/types.rb', line 41 def initialize(props) @props = props end |
Instance Attribute Details
#props ⇒ Object (readonly)
Returns the value of attribute props.
39 40 41 |
# File 'lib/odin/forms/types.rb', line 39 def props @props end |
Instance Method Details
#[](key) ⇒ Object
53 54 55 |
# File 'lib/odin/forms/types.rb', line 53 def [](key) @props[key] end |
#field? ⇒ Boolean
61 62 63 |
# File 'lib/odin/forms/types.rb', line 61 def field? ElementType.field?(type) end |
#key?(key) ⇒ Boolean
57 58 59 |
# File 'lib/odin/forms/types.rb', line 57 def key?(key) @props.key?(key) end |
#name ⇒ Object
49 50 51 |
# File 'lib/odin/forms/types.rb', line 49 def name @props[:name] end |
#type ⇒ Object
45 46 47 |
# File 'lib/odin/forms/types.rb', line 45 def type @props[:type] end |