Class: Crowdskout::Components::FieldOptions
- Defined in:
- lib/crowdskout/components/fields/field_options.rb
Instance Attribute Summary collapse
-
#collection ⇒ Object
Returns the value of attribute collection.
-
#id ⇒ Object
Returns the value of attribute id.
-
#options ⇒ Object
Returns the value of attribute options.
Class Method Summary collapse
-
.create(props) ⇒ FieldOptions
Factory method to create an FieldOptions object from a json string.
Instance Method Summary collapse
-
#add_options(option) ⇒ Array
Add an Option.
Methods inherited from Component
get_value, #to_hash, to_hash_value, #to_json
Instance Attribute Details
#collection ⇒ Object
Returns the value of attribute collection.
10 11 12 |
# File 'lib/crowdskout/components/fields/field_options.rb', line 10 def collection @collection end |
#id ⇒ Object
Returns the value of attribute id.
10 11 12 |
# File 'lib/crowdskout/components/fields/field_options.rb', line 10 def id @id end |
#options ⇒ Object
Returns the value of attribute options.
10 11 12 |
# File 'lib/crowdskout/components/fields/field_options.rb', line 10 def @options end |
Class Method Details
.create(props) ⇒ FieldOptions
Factory method to create an FieldOptions object from a json string
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/crowdskout/components/fields/field_options.rb', line 15 def self.create(props) obj = FieldOptions.new if props props.each do |key, value| if key.downcase == 'options' if value obj. = [] value.each do |option| obj. << Components::Option.create(option) end end else obj.send("#{key}=", value) if obj.respond_to? key end end end obj end |
Instance Method Details
#add_options(option) ⇒ Array
Add an Option
37 38 39 40 |
# File 'lib/crowdskout/components/fields/field_options.rb', line 37 def (option) @options = [] if @options.nil? @options << option end |