class HecksAdapters::SQLDatabase::Commands::Update::DeleteReferences
Delete
references to old values
Attributes
attributes[R]
Public Class Methods
new(table:, attributes:, reference:)
click to toggle source
# File lib/commands/update/delete_references.rb, line 9 def initialize(table:, attributes:, reference:) @table = table @attributes = attributes @reference = reference @where_clause = {} @dataset = DB[JoinTable.new(@table, @reference).name.to_sym] end
Public Instance Methods
call()
click to toggle source
# File lib/commands/update/delete_references.rb, line 17 def call # build_where_clause delete_references remove_references_from_attributes self end
Private Instance Methods
build_where_clause()
click to toggle source
# File lib/commands/update/delete_references.rb, line 26 def build_where_clause DB[JoinTable.new(@table, @reference).name.to_sym] end
delete_references()
click to toggle source
# File lib/commands/update/delete_references.rb, line 34 def delete_references return unless @reference.list? @dataset.where(@where_clause).delete end
remove_references_from_attributes()
click to toggle source
# File lib/commands/update/delete_references.rb, line 30 def remove_references_from_attributes @attributes.delete(@reference.name.to_sym) end