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
Direct Known Subclasses
Constant Summary collapse
- ALL_DRIP_OPTIONS =
[:mailer_class, :mailer, :start, :using, :step]
- VALID_DRIP_OPTIONS =
ALL_DRIP_OPTIONS + [:delay, :start, :at, :on].freeze
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.
Class Method Summary collapse
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
-
#type ⇒ Object
allows for hitting type.periodical? or type.drip?.
Constructor Details
#initialize(dripper, action, options, &block) ⇒ Drip
Returns a new instance of Drip.
49 50 51 52 53 54 |
# File 'lib/caffeinate/drip.rb', line 49 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.
47 48 49 |
# File 'lib/caffeinate/drip.rb', line 47 def action @action end |
#block ⇒ Object (readonly)
Returns the value of attribute block.
47 48 49 |
# File 'lib/caffeinate/drip.rb', line 47 def block @block end |
#dripper ⇒ Object (readonly)
Returns the value of attribute dripper.
47 48 49 |
# File 'lib/caffeinate/drip.rb', line 47 def dripper @dripper end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
47 48 49 |
# File 'lib/caffeinate/drip.rb', line 47 def @options end |
Class Method Details
.build(dripper, action, options, &block) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/caffeinate/drip.rb', line 15 def build(dripper, action, , &block) = .with_defaults(dripper.defaults) (dripper, action, ) new(dripper, action, , &block) 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.
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/caffeinate/drip.rb', line 69 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
57 58 59 |
# File 'lib/caffeinate/drip.rb', line 57 def parameterized? [:using] == :parameterized end |
#send_at(mailing = nil) ⇒ Object
61 62 63 |
# File 'lib/caffeinate/drip.rb', line 61 def send_at(mailing = nil) ::Caffeinate::ScheduleEvaluator.call(self, mailing) end |
#type ⇒ Object
allows for hitting type.periodical? or type.drip?
81 82 83 84 85 |
# File 'lib/caffeinate/drip.rb', line 81 def type name = self.class.name.demodulize.delete_suffix("Drip").presence || "Drip" ActiveSupport::StringInquirer.new(name.downcase) end |