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

Returns:

  • (Object)

    the current value of duplicate



33
34
35
# File 'lib/calagator/duplicate_checking/duplicate_squasher.rb', line 33

def duplicate
  @duplicate
end

#model_nameObject

Returns the value of attribute model_name

Returns:

  • (Object)

    the current value of model_name



33
34
35
# File 'lib/calagator/duplicate_checking/duplicate_squasher.rb', line 33

def model_name
  @model_name
end

#primaryObject

Returns the value of attribute primary

Returns:

  • (Object)

    the current value of primary



33
34
35
# File 'lib/calagator/duplicate_checking/duplicate_squasher.rb', line 33

def primary
  @primary
end

Instance Method Details

#squashObject



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/calagator/duplicate_checking/duplicate_squasher.rb', line 34

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

  squash_associations

  duplicate.update_attribute(:duplicate_of, primary)
  duplicate
end