Class: Calagator::DuplicateChecking::DuplicateSquasher::SingleSquasher

Inherits:
Struct
  • Object
show all
Defined in:
lib/calagator/duplicate_checking/duplicate_squasher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#duplicateObject

Returns the value of attribute duplicate



28
29
30
# File 'lib/calagator/duplicate_checking/duplicate_squasher.rb', line 28

def duplicate
  @duplicate
end

#masterObject

Returns the value of attribute master



28
29
30
# File 'lib/calagator/duplicate_checking/duplicate_squasher.rb', line 28

def master
  @master
end

#model_nameObject

Returns the value of attribute model_name



28
29
30
# File 'lib/calagator/duplicate_checking/duplicate_squasher.rb', line 28

def model_name
  @model_name
end

Instance Method Details

#squashObject



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/calagator/duplicate_checking/duplicate_squasher.rb', line 29

def squash
  # Transfer any venues that use this now duplicate venue as a master
  if duplicate.duplicates.any?
    DuplicateSquasher.new(master, duplicate.duplicates, model_name).squash
  end

  squash_associations

  duplicate.update_attribute(:duplicate_of, master)
  duplicate
end