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, ViaJavascript
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 Method Summary collapse
Instance Attribute Details
#field ⇒ Object
Returns the value of attribute field
55 56 57 |
# File 'lib/chop/form.rb', line 55 def field @field end |
#label ⇒ Object
Returns the value of attribute label
55 56 57 |
# File 'lib/chop/form.rb', line 55 def label @label end |
#path ⇒ Object
Returns the value of attribute path
55 56 57 |
# File 'lib/chop/form.rb', line 55 def path @path end |
#session ⇒ Object
Returns the value of attribute session
55 56 57 |
# File 'lib/chop/form.rb', line 55 def session @session end |
#value ⇒ Object
Returns the value of attribute value
55 56 57 |
# File 'lib/chop/form.rb', line 55 def value @value end |
Class Method Details
.candidates ⇒ Object
69 70 71 72 73 |
# File 'lib/chop/form.rb', line 69 def self.candidates descendants.sort_by do |a| a == Chop::Form::Default ? 1 : -1 # ensure Default comes last end end |
.for(session, label, value, path) ⇒ Object
56 57 58 59 60 61 |
# File 'lib/chop/form.rb', line 56 def self.for session, label, value, path field = session.find_field(label) candidates.map do |klass| klass.new(session, label, value, path, field) end.find(&:matches?) end |
.from(session, field) ⇒ Object
63 64 65 66 67 |
# File 'lib/chop/form.rb', line 63 def self.from session, field candidates.map do |klass| klass.new(session, nil, nil, nil, field) end.find(&:matches?) end |
Instance Method Details
#get_value ⇒ Object
75 76 77 |
# File 'lib/chop/form.rb', line 75 def get_value field.value end |