Module: InverseOf::Associations::HasOneAssociation

Defined in:
lib/inverse_of.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



195
196
197
198
199
# File 'lib/inverse_of.rb', line 195

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

Instance Method Details

#find_target_with_inverse_ofObject



201
202
203
204
205
# File 'lib/inverse_of.rb', line 201

def find_target_with_inverse_of
  target = find_target_without_inverse_of
  set_inverse_instance(target, @owner)
  target
end

#replace_with_inverse_of(record, dont_save = false) ⇒ Object



207
208
209
210
211
# File 'lib/inverse_of.rb', line 207

def replace_with_inverse_of(record, dont_save = false)
  value = replace_without_inverse_of(record, dont_save)
  set_inverse_instance(record, @owner)
  value
end