class Crowdskout::Components::Profile
Attributes
collections[RW]
id[RW]
Public Class Methods
create(props)
click to toggle source
Factory method to create an Profile
object from a json string @param [Hash] props - properties to create object from @return [Profile]
# 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
Public Instance Methods
add_genders(gender)
click to toggle source
Add a Gender @param [Gebder] gender @return [Array] the genders array
# File lib/crowdskout/components/profiles/profile.rb, line 43 def add_genders(gender) @genders = [] if @genders.nil? @genders << gender end
add_names(name)
click to toggle source
Add a Name @param [Name] name @return [Array] the names array
# File lib/crowdskout/components/profiles/profile.rb, line 35 def add_names(name) @names = [] if @names.nil? @names << name end
to_hash()
click to toggle source
Hash override to generate the correct hash
# File lib/crowdskout/components/profiles/profile.rb, line 49 def to_hash ret_val = { id: id } collections.each do |collection| ret_val.merge! collection.to_hash end ret_val end