Sha256: 106b3a9f216c8d297e4bdfc6a0c07f6a20c9a26c23e4d04a27ae87e120d8f0be
Contents?: true
Size: 922 Bytes
Versions: 2
Compression:
Stored size: 922 Bytes
Contents
# # field.rb # Crowdskout # # Copyright (c) 2016 Kyle Schutt. All rights reserved. module Crowdskout module Components class Field < Component # value can either be a string or a hash attr_accessor :key_name, :value # 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] 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 # Hash override to generate the correct hash def to_hash { key_name => (value.is_a?(Hash) ? value.to_hash : value) } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
crowdskout-0.0.10 | lib/crowdskout/components/profiles/field.rb |
crowdskout-0.0.9 | lib/crowdskout/components/profiles/field.rb |