Method: SimpleRecord::ActiveSdb::Base#delete_attributes

Defined in:
lib/simple_record/active_sdb.rb

#delete_attributes(*attrs_list) ⇒ Object

Removes specified attributes from the item. attrs_list is an array or comma separated list of attributes names. Returns the list of deleted attributes.

sandy = Client.find_by_name 'Sandy'
sandy.reload
puts sandy.inspect                   #=> #<Client:0xb7761d28 @new_record=false, @attributes={"name"=>["Sandy"], "id"=>"b2832ce2-e461-11dc-b13c-001bfc466dd7", "toys"=>["boys", "kids", "patchwork"}>
puts sandy.delete_attributes('toys') #=> ['toys']
puts sandy.inspect                   #=> #<Client:0xb7761d28 @new_record=false, @attributes={"name"=>["Sandy"], "id"=>"b2832ce2-e461-11dc-b13c-001bfc466dd7"}>


950
951
952
953
954
955
956
957
958
959
# File 'lib/simple_record/active_sdb.rb', line 950

def delete_attributes(*attrs_list)
    raise_on_id_absence
    attrs_list = attrs_list.flatten.map { |attribute| attribute.to_s }
    attrs_list.delete('id')
    unless attrs_list.blank?
        connection.delete_attributes(domain, id, attrs_list)
        attrs_list.each { |attribute| @attributes.delete(attribute) }
    end
    attrs_list
end