Module: InverseOf::Associations::AssociationCollection

Defined in:
lib/inverse_of.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



67
68
69
70
# File 'lib/inverse_of.rb', line 67

def self.included(base)
  base.alias_method_chain :find_target, :inverse_of
  base.alias_method_chain :add_record_to_target_with_callbacks, :inverse_of
end

Instance Method Details

#add_record_to_target_with_callbacks_with_inverse_of(record, &block) ⇒ Object



80
81
82
83
84
# File 'lib/inverse_of.rb', line 80

def add_record_to_target_with_callbacks_with_inverse_of(record, &block)
  record = add_record_to_target_with_callbacks_without_inverse_of(record, &block)
  set_inverse_instance(record, @owner)
  record
end

#find_target_with_inverse_ofObject



72
73
74
75
76
77
78
# File 'lib/inverse_of.rb', line 72

def find_target_with_inverse_of
  records = find_target_without_inverse_of
  records.each do |record|
    set_inverse_instance(record, @owner)
  end
  records
end