Class: ArchivalRecordCore::ArchivalRecord::AssociationOperation::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/archival_record_core/association_operation/base.rb

Direct Known Subclasses

Archive, Unarchive

Constant Summary collapse

ACTIVE_RECORD_REQUIREMENT_DESTROY_ASYNC =
Gem::Requirement.new(">= 6.1.0")
DEPENDENT_OPTIONS_TO_OPERATE_ON_RAILS_6_0 =

:destroy_async was added as an option in rails 6.1 but seems very buggy there wrt to configuration

%i[
  destroy
  delete_all
].freeze
DEPENDENT_OPTIONS_TO_OPERATE_ON_RAILS =
%i[
  destroy
  destroy_async
  delete_all
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model, head_archive_number) ⇒ Base

Returns a new instance of Base.



23
24
25
26
# File 'lib/archival_record_core/association_operation/base.rb', line 23

def initialize(model, head_archive_number)
  @model = model
  @head_archive_number = head_archive_number
end

Instance Attribute Details

#head_archive_numberObject (readonly)

Returns the value of attribute head_archive_number.



21
22
23
# File 'lib/archival_record_core/association_operation/base.rb', line 21

def head_archive_number
  @head_archive_number
end

#modelObject (readonly)

Returns the value of attribute model.



21
22
23
# File 'lib/archival_record_core/association_operation/base.rb', line 21

def model
  @model
end

Instance Method Details

#executeObject



28
29
30
31
32
33
34
# File 'lib/archival_record_core/association_operation/base.rb', line 28

def execute
  return unless model.archive_dependents?

  each_archivable_association do |association|
    act_on_association(association) if association_conditions_met?(association)
  end
end