Class: Odin::Forms::FormElement

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#propsObject (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

Returns:

  • (Boolean)


61
62
63
# File 'lib/odin/forms/types.rb', line 61

def field?
  ElementType.field?(type)
end

#key?(key) ⇒ Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/odin/forms/types.rb', line 57

def key?(key)
  @props.key?(key)
end

#nameObject



49
50
51
# File 'lib/odin/forms/types.rb', line 49

def name
  @props[:name]
end

#typeObject



45
46
47
# File 'lib/odin/forms/types.rb', line 45

def type
  @props[:type]
end