Method: AMEE::Data::ItemValueHistory#save!

Defined in:
lib/amee/data_item_value_history.rb

#save!Object

Raises:



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/amee/data_item_value_history.rb', line 116

def save!
  raise AMEE::BadData.new("Can't save without a path") unless @path
  raise AMEE::BadData.new("Can't save without a connection") unless @connection
  origin=ItemValueHistory.get(connection,full_path)
  changes=compare(origin)
  changes[:updates].each do |update|
    # we've decided to identify these, but the version in the thing to be
    # saved is probably home made, so copy over the uid
    update.uid=origin.value_at(update.start_date).uid
    update.save!
  end
  changes[:insertions].each do |insertion|
    insertion.create!
  end
  changes[:deletions].each do |deletion|
    deletion.delete!
  end
end