Method: SimpleRecord::ActiveSdb::Base#put_attributes
- Defined in:
- lib/simple_record/active_sdb.rb
#put_attributes(attrs) ⇒ Object
Stores specified attributes. attrs is a hash: { attribute1 => values1, …, attributeN => valuesN }. Returns a hash of saved attributes.
see to put method
822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 |
# File 'lib/simple_record/active_sdb.rb', line 822 def put_attributes(attrs) attrs = uniq_values(attrs) prepare_for_update # if 'id' is present in attrs hash: # replace internal 'id' attribute and remove it from the attributes to be sent @attributes['id'] = attrs['id'] unless attrs['id'].blank? attrs.delete('id') # add new values to all attributes from list connection.put_attributes(domain, id, attrs) unless attrs.blank? connection.put_attributes(domain, id, {'id' => id}, :replace) attrs.each do |attribute, values| @attributes[attribute] ||= [] @attributes[attribute] += values @attributes[attribute].uniq! end mark_as_old attributes end |