Class: Caffeinate::Drip
- Inherits:
-
Object
- Object
- Caffeinate::Drip
- Defined in:
- lib/caffeinate/drip.rb
Overview
A Drip object
Handles the block and provides convenience methods for the drip
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#dripper ⇒ Object
readonly
Returns the value of attribute dripper.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#enabled?(mailing) ⇒ Boolean
Checks if the drip is enabled.
-
#initialize(dripper, action, options, &block) ⇒ Drip
constructor
A new instance of Drip.
-
#parameterized? ⇒ Boolean
If the associated ActionMailer uses ‘ActionMailer::Parameterized` initialization instead of argument-based initialization.
- #send_at(mailing = nil) ⇒ Object
Constructor Details
#initialize(dripper, action, options, &block) ⇒ Drip
Returns a new instance of Drip.
13 14 15 16 17 18 |
# File 'lib/caffeinate/drip.rb', line 13 def initialize(dripper, action, , &block) @dripper = dripper @action = action @options = @block = block end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
11 12 13 |
# File 'lib/caffeinate/drip.rb', line 11 def action @action end |
#block ⇒ Object (readonly)
Returns the value of attribute block.
11 12 13 |
# File 'lib/caffeinate/drip.rb', line 11 def block @block end |
#dripper ⇒ Object (readonly)
Returns the value of attribute dripper.
11 12 13 |
# File 'lib/caffeinate/drip.rb', line 11 def dripper @dripper end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
11 12 13 |
# File 'lib/caffeinate/drip.rb', line 11 def @options end |
Instance Method Details
#enabled?(mailing) ⇒ Boolean
Checks if the drip is enabled
This is kind of messy and could use some love. todo: better.
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/caffeinate/drip.rb', line 33 def enabled?(mailing) catch(:abort) do if dripper.run_callbacks(:before_drip, self, mailing) return DripEvaluator.new(mailing).call(&@block) else return false end end false end |
#parameterized? ⇒ Boolean
If the associated ActionMailer uses ‘ActionMailer::Parameterized` initialization instead of argument-based initialization
21 22 23 |
# File 'lib/caffeinate/drip.rb', line 21 def parameterized? [:using] == :parameterized end |
#send_at(mailing = nil) ⇒ Object
25 26 27 |
# File 'lib/caffeinate/drip.rb', line 25 def send_at(mailing = nil) ::Caffeinate::ScheduleEvaluator.call(self, mailing) end |