Class: Caffeinate::ScheduleEvaluator
- Inherits:
-
Object
- Object
- Caffeinate::ScheduleEvaluator
- Defined in:
- lib/caffeinate/schedule_evaluator.rb
Instance Attribute Summary collapse
-
#mailing ⇒ Object
readonly
Returns the value of attribute mailing.
Class Method Summary collapse
Instance Method Summary collapse
-
#call ⇒ Object
todo: test this decision tree.
-
#initialize(drip, mailing) ⇒ ScheduleEvaluator
constructor
A new instance of ScheduleEvaluator.
- #method_missing(method, *args, &block) ⇒ Object
- #respond_to_missing?(name, include_private = false) ⇒ Boolean
Constructor Details
#initialize(drip, mailing) ⇒ ScheduleEvaluator
Returns a new instance of ScheduleEvaluator.
28 29 30 31 |
# File 'lib/caffeinate/schedule_evaluator.rb', line 28 def initialize(drip, mailing) @drip = drip @mailing = mailing end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
60 61 62 |
# File 'lib/caffeinate/schedule_evaluator.rb', line 60 def method_missing(method, *args, &block) @drip.send(method, *args, &block) end |
Instance Attribute Details
#mailing ⇒ Object (readonly)
Returns the value of attribute mailing.
27 28 29 |
# File 'lib/caffeinate/schedule_evaluator.rb', line 27 def mailing @mailing end |
Class Method Details
.call(drip, mailing) ⇒ Object
23 24 25 |
# File 'lib/caffeinate/schedule_evaluator.rb', line 23 def self.call(drip, mailing) new(drip, mailing).call end |
Instance Method Details
#call ⇒ Object
todo: test this decision tree.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/caffeinate/schedule_evaluator.rb', line 34 def call if periodical? start = mailing.instance_exec(&[:start]) start += [:every] if mailing.caffeinate_campaign_subscription.caffeinate_mailings.count.positive? date = start.from_now elsif [:on] date = OptionEvaluator.new([:on], self, mailing).call else date = OptionEvaluator.new([:delay], self, mailing).call if date.respond_to?(:from_now) date = date.from_now end end if [:at] time = OptionEvaluator.new([:at], self, mailing).call return date.change(hour: time.hour, min: time.min, sec: time.sec) end date end |
#respond_to_missing?(name, include_private = false) ⇒ Boolean
56 57 58 |
# File 'lib/caffeinate/schedule_evaluator.rb', line 56 def respond_to_missing?(name, include_private = false) @drip.respond_to?(name, include_private) end |