Class: Crowdskout::Components::Profile
- Defined in:
- lib/crowdskout/components/profiles/profile.rb
Instance Attribute Summary collapse
-
#collections ⇒ Object
Returns the value of attribute collections.
-
#id ⇒ Object
Returns the value of attribute id.
Class Method Summary collapse
-
.create(props) ⇒ Profile
Factory method to create an Profile object from a json string.
Instance Method Summary collapse
-
#add_genders(gender) ⇒ Array
Add a Gender.
-
#add_names(name) ⇒ Array
Add a Name.
Methods inherited from Component
get_value, #to_hash, to_hash_value, #to_json
Instance Attribute Details
#collections ⇒ Object
Returns the value of attribute collections.
10 11 12 |
# File 'lib/crowdskout/components/profiles/profile.rb', line 10 def collections @collections end |
#id ⇒ Object
Returns the value of attribute id.
10 11 12 |
# File 'lib/crowdskout/components/profiles/profile.rb', line 10 def id @id end |
Class Method Details
.create(props) ⇒ Profile
Factory method to create an Profile object from a json string
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/crowdskout/components/profiles/profile.rb', line 15 def self.create(props) obj = Profile.new obj.collections = [] if props props.each do |key, value| if ['id'].include? key.downcase obj.send("#{key}=", value) if obj.respond_to? key else # the key is the name of the collection # the value is an array of items obj.collections << Components::Collection.create(key, value) end end end obj end |
Instance Method Details
#add_genders(gender) ⇒ Array
Add a Gender
43 44 45 46 |
# File 'lib/crowdskout/components/profiles/profile.rb', line 43 def add_genders(gender) @genders = [] if @genders.nil? @genders << gender end |
#add_names(name) ⇒ Array
Add a Name
35 36 37 38 |
# File 'lib/crowdskout/components/profiles/profile.rb', line 35 def add_names(name) @names = [] if @names.nil? @names << name end |