Class: Refer::Referral

Inherits:
ApplicationRecord show all
Defined in:
app/models/refer/referral.rb

Instance Method Summary collapse

Instance Method Details

#complete!(**attributes) ⇒ Object



19
20
21
22
23
24
# File 'app/models/refer/referral.rb', line 19

def complete!(**attributes)
  return if completed_at?

  update attributes.with_defaults(completed_at: Time.current)
  Refer.referral_completed&.call(self)
end

#ensure_not_self_referralObject



15
16
17
# File 'app/models/refer/referral.rb', line 15

def ensure_not_self_referral
  errors.add(:base, "Self-referrals are not allowed") if referrer == referee
end