class Crowdskout::Components::FieldOptions

Attributes

collection[RW]
id[RW]
options[RW]

Public Class Methods

create(props) click to toggle source

Factory method to create an FieldOptions object from a json string @param [Hash] props - properties to create object from @return [FieldOptions]

# 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.options = []
          value.each do |option|
            obj.options << Components::Option.create(option)
          end
        end
      else
        obj.send("#{key}=", value) if obj.respond_to? key
      end
    end
  end
  obj
end

Public Instance Methods

add_options(option) click to toggle source

Add an Option @param [Option] option @return [Array] the options array

# File lib/crowdskout/components/fields/field_options.rb, line 37
def add_options(option)
  @options = [] if @options.nil?
  @options << option
end