Sets the attributes from a hash
165426
def update_attributes_without_saving(hash)
      hash.each do |k, v|
        raise NoMethodError, "#{k}= method not available, use property :#{k}" unless self.respond_to?("#{k}=")
      end      
      hash.each do |k, v|
        self.send("#{k}=",v)
      end
    end
1282034
def set(key, value = nil)
      if key.is_a?(Hash)
        properties.merge!(key)
      else
        properties[key] = value
      end
    end
685728
def from_hash(attributes)
      case attributes
      when Hash
        attributes.map{|k,v| find_or_create_by(key: k).update!(value: v)}
        Rails.cache.clear
        true
      else
        raise ArgumentError, 'Hash required', caller
      end
    end
1368723
def update_attributes(attrs)
      if id = attrs.delete(:id)
        @id = id
      end
      attrs.each do |key, value|
        setter = :"#{key}="
        send(setter, value) if respond_to?(setter)
      end
    end
291645
def set_parameters(hash_or_instance)
      parameters = extract_parameters_from_hash_or_instance(hash_or_instance)
      parameters.each do |k,v|
        send "#{k}=", v
      end
    end
691504
def to_output_hash
      HASH_SCHEMA.schema(
        map { |attr| [attr.key, attr.to_read_type] }.to_h
      )
    end
29183
def from_hash(hash:, klass:, use_alias: false)
      validate_class_kit(klass)

      return hash.map { |i| from_hash(hash: i, klass: klass, use_alias: use_alias) } if hash.is_a?(Array)

      @hash_helper.indifferent!(hash)
      entity = klass.new
      attributes = @attribute_helper.get_attributes(klass)
      attributes.each do |attribute|
        key = use_alias ? (attribute[:alias] || attribute[:name]) : attribute[:name]
        type = attribute[:type]

        # if the hash value is nil skip it
        next if hash[key].nil?

        value = if is_class_kit?(type)
                  from_hash(hash: hash[key], klass: type, use_alias: use_alias)
                elsif type == Array
                  hash[key].map do |array_element|
                    if attribute[:collection_type].nil?
                      array_element
                    else
                      if is_class_kit?(attribute[:collection_type])
                        from_hash(hash: array_element, klass: attribute[:collection_type], use_alias: use_alias)
                      else
                        @value_helper.parse(type: attribute[:collection_type], value: array_element)
                      end
                    end
                  end
                else
                  hash[key]
                end

        entity.public_send(:"#{attribute[:name]}=", value)
      end

      entity
    end
192945
def transform_hash(hash, path = "")
      hash.each_with_object({}) do |(k, v), ret|
        key = path + k.to_s

        if v.is_a?(Hash)
          ret.merge! transform_hash(v, "#{key}:")
        else
          ret[key] = v
        end
      end
    end
1009516
def serialize_attributes
    attr_hash = {}
    @attributes.each_pair do |name,value|
      attr_hash[name] = serialize_attribute(name,value)
    end
    attr_hash[:id] = serialize_id unless new?
    attr_hash
  end
1230386
def to_hash
      hash = {}
      attributes = self.class.attribute_map.sort_by {|key,value| key}
      attributes.each { |attr, param|
        value = self.send(attr)
        next if value.nil?
        if value.is_a?(Array)
          hash[param] = value.compact.map{ |v| _to_hash(v) }
        else
          hash[param] = _to_hash(value)
        end
      }
      hash
    end
1110882
def group_attributes_by_key(attributes)
      Hash[attributes.group_by(&:first).map { |k, v| [k, v.map(&:last).tap(&:compact!).join(', ')] }]
    end
565868
def set(object, attributes)
      coerce(attributes).each do |name, value|
        writer_name = "#{name}="
        if object.allowed_writer_methods.include?(writer_name)
          object.__send__(writer_name, value)
        end
      end
    end
652810
def set_all(params = self.class::DEFAULT_REQUEST_HEADER)
      params = params.data if params.class <= Resource
      params = Hash[params.map { |(k, v)| [k.to_s, v] }]
      params.each { |key, value| set(key.to_s, value) }
      self
    end
767047
def to_h
      hash = {}
      [:bri, :hue, :sat].each do |attr|
        value = send(attr)
        hash[attr] = value if value
      end
      hash
    end
970765
def set_hash(self, algo, digest):
        """"""
        self.algo = algo
        self.digest = digest
362630
def create(attributes_hash)
      #the tap method allows preconfigured methods and values to
      #be associated with the instance during instantiation while also automatically returning
      #the object after its creation is concluded.
      self.new.tap do |card|
        attributes_hash.each do |key, value|
          #sending the new instance the key name as a setter with the value
          card.send("#{key}=", value)
          #string interpolation is used as the method doesn't know the key name yet
          #but an = sign is implemented into the string in order to asssociate it as a setter
        end
        #saves the new instance into the database
        card.save
      end
    end
215612
def to_hash
      {}.tap do |hash|
        _attributes.each do |key, value|
          hash[key] = value.respond_to?(:to_hash) ? value.to_hash : value
        end
      end
    end