Class: FactoryForm::Field
- Inherits:
-
Object
- Object
- FactoryForm::Field
- Defined in:
- lib/factoryform/field.rb
Overview
Field is simply a hash of different attributes
Direct Known Subclasses
Boolean, Currency, ImageData, LongAnswer, MultipleChoice, Rating, ShortAnswer, TextData
Instance Attribute Summary collapse
-
#field_type ⇒ Object
Returns the value of attribute field_type.
-
#hint ⇒ Object
Returns the value of attribute hint.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#label ⇒ Object
Returns the value of attribute label.
-
#required ⇒ Object
Returns the value of attribute required.
-
#unique ⇒ Object
Returns the value of attribute unique.
-
#validation_format ⇒ Object
Returns the value of attribute validation_format.
Instance Method Summary collapse
-
#initialize(options) ⇒ Field
constructor
A new instance of Field.
Constructor Details
#initialize(options) ⇒ Field
Returns a new instance of Field.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/factoryform/field.rb', line 7 def initialize() unless .nil? || [:id].nil? || [:label].nil? = [:options] || { } .merge!({ # defaults :hint => [:hint] || " ", :required => [:required] || true, :unique => [:unique] || false, :validation_format => [:validation_format] || "general", }) .merge!({:options => }) @id, @label, @hint, @required, @unique, @validation_format, @field_type = [:id], [:label],[:options][:hint], [:options][:required], [:options][:unique], [:options][:validation_format], [:field_type] else raise(ParameterExpectedException, "Missing ID and label") end end |
Instance Attribute Details
#field_type ⇒ Object
Returns the value of attribute field_type.
5 6 7 |
# File 'lib/factoryform/field.rb', line 5 def field_type @field_type end |
#hint ⇒ Object
Returns the value of attribute hint.
5 6 7 |
# File 'lib/factoryform/field.rb', line 5 def hint @hint end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/factoryform/field.rb', line 4 def id @id end |
#label ⇒ Object
Returns the value of attribute label.
5 6 7 |
# File 'lib/factoryform/field.rb', line 5 def label @label end |
#required ⇒ Object
Returns the value of attribute required.
5 6 7 |
# File 'lib/factoryform/field.rb', line 5 def required @required end |
#unique ⇒ Object
Returns the value of attribute unique.
5 6 7 |
# File 'lib/factoryform/field.rb', line 5 def unique @unique end |
#validation_format ⇒ Object
Returns the value of attribute validation_format.
5 6 7 |
# File 'lib/factoryform/field.rb', line 5 def validation_format @validation_format end |