class HecksAdapters::SQLDatabase::Commands::Update::UpdateValues

Update values

Public Class Methods

new(references, attributes, table, id) click to toggle source
# File lib/commands/update/update_values.rb, line 7
def initialize(references, attributes, table, id)
  @references = references
  @attributes = attributes
  @reference_ids = {}
  @table = table
  @id = id
end

Public Instance Methods

call() click to toggle source
# File lib/commands/update/update_values.rb, line 15
def call
  @references.each do |reference|
    create_new_value(reference)
    delete_old_references(reference)
    link_to_new_values(reference)
  end
end

Private Instance Methods

create_new_value(reference) click to toggle source
# File lib/commands/update/update_values.rb, line 25
def create_new_value(reference)
  @reference_ids = CreateNewValue.new(
    reference: reference,
    attributes: @attributes,
    reference_ids: @reference_ids
  ).call.reference_ids
end
delete_old_references(reference) click to toggle source
# File lib/commands/update/update_values.rb, line 33
def delete_old_references(reference)
  @attributes = DeleteReferences.new(
    reference: reference,
    table: @table,
    attributes: @attributes
  ).call.attributes
end