Class: Chop::Form::Field
- Inherits:
-
Struct
- Object
- Struct
- Chop::Form::Field
- Defined in:
- lib/chop/form.rb
Direct Known Subclasses
Checkbox, Default, MultipleCheckbox, MultipleFile, MultipleSelect, Radio, Select, SingleFile
Instance Attribute Summary collapse
-
#field ⇒ Object
Returns the value of attribute field.
-
#label ⇒ Object
Returns the value of attribute label.
-
#path ⇒ Object
Returns the value of attribute path.
-
#session ⇒ Object
Returns the value of attribute session.
-
#value ⇒ Object
Returns the value of attribute value.
Class Method Summary collapse
Instance Attribute Details
#field ⇒ Object
Returns the value of attribute field
23 24 25 |
# File 'lib/chop/form.rb', line 23 def field @field end |
#label ⇒ Object
Returns the value of attribute label
23 24 25 |
# File 'lib/chop/form.rb', line 23 def label @label end |
#path ⇒ Object
Returns the value of attribute path
23 24 25 |
# File 'lib/chop/form.rb', line 23 def path @path end |
#session ⇒ Object
Returns the value of attribute session
23 24 25 |
# File 'lib/chop/form.rb', line 23 def session @session end |
#value ⇒ Object
Returns the value of attribute value
23 24 25 |
# File 'lib/chop/form.rb', line 23 def value @value end |
Class Method Details
.for(session, label, value, path) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/chop/form.rb', line 24 def self.for session, label, value, path field = session.find_field(label) candidates = descendants.sort_by do |a| a == Chop::Form::Default ? 1 : -1 # ensure Default comes last end candidates.map do |klass| klass.new(session, label, value, path, field) end.find(&:matches?) end |