Class: KickAhead::Job
- Inherits:
-
Object
- Object
- KickAhead::Job
- Defined in:
- lib/kick_ahead/job.rb
Class Method Summary collapse
-
.class_attribute(name) ⇒ Object
Simplified version extracted from ActiveSupport.
- .run_at(time, *args) ⇒ Object
- .run_in(delta, *args) ⇒ Object
Instance Method Summary collapse
Class Method Details
.class_attribute(name) ⇒ Object
Simplified version extracted from ActiveSupport
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/kick_ahead/job.rb', line 6 def self.class_attribute(name) define_singleton_method(name) { nil } ivar = "@#{name}" define_singleton_method("#{name}=") do |val| singleton_class.class_eval do define_method(name) { val } end if singleton_class? class_eval do define_method(name) do if instance_variable_defined? ivar instance_variable_get ivar else singleton_class.send name end end end end val end end |
.run_at(time, *args) ⇒ Object
41 42 43 |
# File 'lib/kick_ahead/job.rb', line 41 def self.run_at(time, *args) KickAhead.repository.create(name, time, *args) end |
.run_in(delta, *args) ⇒ Object
37 38 39 |
# File 'lib/kick_ahead/job.rb', line 37 def self.run_in(delta, *args) KickAhead.repository.create(name, KickAhead.current_time.call + delta, *args) end |
Instance Method Details
#perform ⇒ Object
45 46 47 |
# File 'lib/kick_ahead/job.rb', line 45 def perform(*) raise NotImplementedError end |