class Crowdskout::Components::Field

Attributes

key_name[RW]

value can either be a string or a hash

value[RW]

value can either be a string or a hash

Public Class Methods

create(props) click to toggle source

Factory method to create an Field object from a json string @param [String] key_name - name of the Field @param [Hash or String] value - properties to create object from @return [Field]

# File lib/crowdskout/components/profiles/field.rb, line 17
def self.create(props)
  obj = Field.new
  props.each do |key, value|
    obj.key_name = key
    if value.is_a?(Hash)
      obj.value = Value.create(value)
    else
      obj.value = value
    end
  end
  obj
end

Public Instance Methods

to_hash() click to toggle source

Hash override to generate the correct hash

# File lib/crowdskout/components/profiles/field.rb, line 31
def to_hash
  {
    key_name => (value.to_hash rescue value)
  }
end