Module: Caffeinate::Dripper::Drip::ClassMethods
- Defined in:
- lib/caffeinate/dripper/drip.rb
Instance Method Summary collapse
-
#drip(action_name, options = {}, &block) ⇒ Object
Register a drip on the Dripper.
-
#drip_collection ⇒ Object
A collection of Drip objects associated with a given ‘Caffeinate::Dripper`.
-
#drips ⇒ Object
A collection of Drip objects associated with a given ‘Caffeinate::Dripper`.
-
#periodical_drip(action_name, options = {}, &block) ⇒ Object
Register a Periodical drip on the Dripper.
Instance Method Details
#drip(action_name, options = {}, &block) ⇒ Object
Register a drip on the Dripper
drip :mailer_action_name, mailer_class: "MailerClass", step: 1, delay: 1.hour
Accepts a block, symbol (an instance method on the Dripper that accepts two arguments: drip, mailing), or a string to be later parsed into a Time object.
drip :mailer_action_name, mailer_class: "MailerClass", at: -> { 3.days.from_now.in_time_zone(mailing.subscriber.timezone) }
class MyDripper
drip :mailer_action_name, mailer_class: "MailerClass", at: :generate_date
def generate_date(drip, mailing)
3.days.from_now.in_time_zone(mailing.subscriber.timezone)
end
end
drip :mailer_action_name, mailer_class: "MailerClass", at: 'January 1, 2022'
49 50 51 |
# File 'lib/caffeinate/dripper/drip.rb', line 49 def drip(action_name, = {}, &block) drip_collection.register(action_name, , ::Caffeinate::Drip, &block) end |
#drip_collection ⇒ Object
A collection of Drip objects associated with a given ‘Caffeinate::Dripper`
15 16 17 |
# File 'lib/caffeinate/dripper/drip.rb', line 15 def drip_collection @drip_collection ||= DripCollection.new(self) end |
#drips ⇒ Object
A collection of Drip objects associated with a given ‘Caffeinate::Dripper`
20 21 22 |
# File 'lib/caffeinate/dripper/drip.rb', line 20 def drips drip_collection.values end |
#periodical_drip(action_name, options = {}, &block) ⇒ Object
Register a Periodical drip on the Dripper
periodical :pay_your_invoice, every: 1.day, start: 0.hours, if: :invoice_unpaid?
76 77 78 |
# File 'lib/caffeinate/dripper/drip.rb', line 76 def periodical_drip(action_name, = {}, &block) drip_collection.register(action_name, , ::Caffeinate::PeriodicalDrip, &block) end |