Class: Crowdskout::Components::Value
- Defined in:
- lib/crowdskout/components/profiles/value.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#value ⇒ Object
Returns the value of attribute value.
Class Method Summary collapse
-
.create(props) ⇒ Value
Factory method to create an Value object from a json string.
Methods inherited from Component
get_value, #to_hash, to_hash_value, #to_json
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
10 11 12 |
# File 'lib/crowdskout/components/profiles/value.rb', line 10 def id @id end |
#value ⇒ Object
Returns the value of attribute value.
10 11 12 |
# File 'lib/crowdskout/components/profiles/value.rb', line 10 def value @value end |
Class Method Details
.create(props) ⇒ Value
Factory method to create an Value object from a json string
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/crowdskout/components/profiles/value.rb', line 15 def self.create(props) obj = Value.new if props props.each do |key, value| if obj.respond_to? key obj.send("#{key}=", value) else # this will create the attribute if it doesn't exist obj.class.send(:attr_accessor, key) obj.instance_variable_set("@#{key}", value) end end end obj end |