Class: Unidom::Contact::ContactSubscription

Inherits:
ApplicationRecord show all
Includes:
Unidom::Common::Concerns::ModelExtension
Defined in:
app/models/unidom/contact/contact_subscription.rb

Overview

Contact Subscription 是联系方式和参与者之间的关联关系。

Class Method Summary collapse

Class Method Details

.subscribe!(contact: nil, subscriber: nil, name: subscriber.try(:name), primary: true, grade: 0, priority: 0, opened_at: Time.now) ⇒ Object



25
26
27
# File 'app/models/unidom/contact/contact_subscription.rb', line 25

def self.subscribe!(contact: nil, subscriber: nil, name: subscriber.try(:name), primary: true, grade: 0, priority: 0, opened_at: Time.now)
  contact_is(contact).subscribed_by(subscriber).valid_at(now: opened_at).alive.first_or_create! name: name, elemental: primary, grade: grade, priority: priority, opened_at: opened_at
end