Module: Moist::Models::Campaign::ClassMethods

Defined in:
lib/moist/models/campaign.rb

Instance Method Summary collapse

Instance Method Details

#[](val) ⇒ Object



21
22
23
24
25
26
# File 'lib/moist/models/campaign.rb', line 21

def [](val)
  campaign = ::Moist::Campaign.find_by(slug: val)
  raise ::Moist::UnknownCampaign, "Unknown campaign slug #{val}" if campaign.nil?

  campaign
end

#subscribe(subscriber, user:) ⇒ Object



28
29
30
# File 'lib/moist/models/campaign.rb', line 28

def subscribe(subscriber, user:)
  SubscriptionManager.new(subscriber, user: user, action: :subscribe)
end

#unsubscribe(subscriber, user:) ⇒ Object



32
33
34
# File 'lib/moist/models/campaign.rb', line 32

def unsubscribe(subscriber, user:)
  SubscriptionManager.new(subscriber, user: user, action: :unsubscribe)
end