Class: Caffeinate::ScheduleEvaluator
- Inherits:
-
Object
- Object
- Caffeinate::ScheduleEvaluator
show all
- Defined in:
- lib/caffeinate/schedule_evaluator.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
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
64
65
66
|
# File 'lib/caffeinate/schedule_evaluator.rb', line 64
def method_missing(method, *args, &block)
@drip.send(method, *args, &block)
end
|
Instance Attribute Details
#mailing ⇒ Object
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/caffeinate/schedule_evaluator.rb', line 34
def call
if periodical?
start = Caffeinate.config.now.call
if options[:start]
start = OptionEvaluator.new(options[:start], self, mailing).call
end
start += OptionEvaluator.new(options[:every], self, mailing).call if mailing.caffeinate_campaign_subscription.caffeinate_mailings.size.positive?
date = start
elsif options[:on]
date = OptionEvaluator.new(options[:on], self, mailing).call
else
date = OptionEvaluator.new(options[:delay], self, mailing).call
end
if date.respond_to?(:from_now)
date = date.from_now
end
if options[:at]
time = OptionEvaluator.new(options[: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
60
61
62
|
# File 'lib/caffeinate/schedule_evaluator.rb', line 60
def respond_to_missing?(name, include_private = false)
@drip.respond_to?(name, include_private)
end
|