Module: Caffeinate::Dripper::Subscriber::ClassMethods

Defined in:
lib/caffeinate/dripper/subscriber.rb

Instance Method Summary collapse

Instance Method Details

#subscribe(subscriber, **args) ⇒ Caffeinate::CampaignSubscriber

Subscribes to the campaign.

OrderDripper.subscribe(order, user: order.user)

Parameters:

  • subscriber (ActiveRecord::Base)

    The object subscribing

  • [ActiveRecord::Base] (Hash)

    a customizable set of options

Returns:

  • (Caffeinate::CampaignSubscriber)

    the created CampaignSubscriber



26
27
28
# File 'lib/caffeinate/dripper/subscriber.rb', line 26

def subscribe(subscriber, **args)
  caffeinate_campaign.subscribe!(subscriber, **args)
end

#subscriptionsObject

Returns the Campaign’s ‘Caffeinate::CampaignSubscriber`



14
15
16
# File 'lib/caffeinate/dripper/subscriber.rb', line 14

def subscriptions
  caffeinate_campaign.caffeinate_campaign_subscriptions
end

#unsubscribe(subscriber, **args) ⇒ Caffeinate::CampaignSubscriber

Unsubscribes from the campaign. Returns false if something’s wrong.

OrderDripper.unsubscribe(order, user: order.user)

Parameters:

  • subscriber (ActiveRecord::Base)

    The object subscribing

  • [ActiveRecord::Base] (Hash)

    a customizable set of options

Returns:

  • (Caffeinate::CampaignSubscriber)

    the CampaignSubscriber



38
39
40
# File 'lib/caffeinate/dripper/subscriber.rb', line 38

def unsubscribe(subscriber, **args)
  caffeinate_campaign.unsubscribe(subscriber, **args)
end

#unsubscribe!(subscriber, **args) ⇒ Caffeinate::CampaignSubscriber

Unsubscribes from the campaign. Raises error if somerthing’s wrong.

OrderDripper.unsubscribe(order, user: order.user)

Parameters:

  • subscriber (ActiveRecord::Base)

    The object subscribing

  • [ActiveRecord::Base] (Hash)

    a customizable set of options

Returns:

  • (Caffeinate::CampaignSubscriber)

    the CampaignSubscriber



50
51
52
# File 'lib/caffeinate/dripper/subscriber.rb', line 50

def unsubscribe!(subscriber, **args)
  caffeinate_campaign.unsubscribe!(subscriber, **args)
end