2017-07-09 13:41:28 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2009-05-01 11:01:13 -04:00
|
|
|
class Man < ActiveRecord::Base
|
2016-08-06 13:37:57 -04:00
|
|
|
has_one :face, inverse_of: :man
|
|
|
|
has_one :polymorphic_face, class_name: "Face", as: :polymorphic_man, inverse_of: :polymorphic_man
|
|
|
|
has_one :polymorphic_face_without_inverse, class_name: "Face", as: :poly_man_without_inverse
|
|
|
|
has_many :interests, inverse_of: :man
|
2019-10-09 18:49:34 -04:00
|
|
|
has_many :interests_with_callbacks,
|
|
|
|
class_name: "Interest",
|
|
|
|
before_add: :add_called,
|
|
|
|
after_add: :add_called,
|
|
|
|
inverse_of: :man_with_callbacks
|
|
|
|
has_many :polymorphic_interests,
|
|
|
|
class_name: "Interest",
|
|
|
|
as: :polymorphic_man,
|
|
|
|
inverse_of: :polymorphic_man
|
|
|
|
has_many :polymorphic_interests_with_callbacks,
|
|
|
|
class_name: "Interest",
|
|
|
|
as: :polymorphic_man,
|
|
|
|
before_add: :add_called,
|
|
|
|
after_add: :add_called,
|
|
|
|
inverse_of: :polymorphic_man
|
2009-05-01 11:01:13 -04:00
|
|
|
# These are "broken" inverse_of associations for the purposes of testing
|
2016-08-06 13:37:57 -04:00
|
|
|
has_one :dirty_face, class_name: "Face", inverse_of: :dirty_man
|
|
|
|
has_many :secret_interests, class_name: "Interest", inverse_of: :secret_man
|
2013-08-15 00:50:49 -04:00
|
|
|
has_one :mixed_case_monkey
|
2019-10-09 18:49:34 -04:00
|
|
|
|
|
|
|
attribute :add_callback_called, :boolean, default: false
|
|
|
|
|
|
|
|
def add_called(_interest)
|
|
|
|
self.add_callback_called = true
|
|
|
|
end
|
2009-05-01 11:01:13 -04:00
|
|
|
end
|
2018-02-05 07:40:44 -05:00
|
|
|
|
|
|
|
class Human < Man
|
|
|
|
end
|