Class: Edamame::Job
- Inherits:
-
Struct
- Object
- Struct
- Edamame::Job
- Includes:
- JobCore
- Defined in:
- lib/edamame/job.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ 'priority' => 65536, 'ttr' => 120, 'state' => 1, 'scheduling' => Edamame::Scheduling::Once.new() }
Instance Attribute Summary collapse
-
#obj ⇒ Object
Returns the value of attribute obj.
-
#priority ⇒ Object
Returns the value of attribute priority.
-
#scheduling ⇒ Object
Returns the value of attribute scheduling.
-
#state ⇒ Object
Returns the value of attribute state.
-
#ttr ⇒ Object
Returns the value of attribute ttr.
-
#tube ⇒ Object
Returns the value of attribute tube.
Instance Method Summary collapse
- #delay ⇒ Object
-
#initialize(*args) ⇒ Job
constructor
attr_accessor :runs, :failures, :prev_run_at.
- #to_hash(flatten = true) ⇒ Object
Methods included from JobCore
Constructor Details
#initialize(*args) ⇒ Job
attr_accessor :runs, :failures, :prev_run_at
103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/edamame/job.rb', line 103 def initialize *args super *args DEFAULT_OPTIONS.each{|key,val| self[key] ||= val } [:priority, :ttr, :state].each{|key| self[key] = self[key].to_i } case self.scheduling when String scheduling_hash = YAML.load(self.scheduling) rescue nil self.scheduling = Scheduling.from_hash(scheduling_hash) if scheduling_hash when Hash self.scheduling = Scheduling.from_hash(scheduling) else raise "Can't build a Scheduling from #{self.scheduling}" ; end if self.obj.is_a?(String) then self.obj = YAML.load(self.obj) rescue nil ; end end |
Instance Attribute Details
#obj ⇒ Object
Returns the value of attribute obj
88 89 90 |
# File 'lib/edamame/job.rb', line 88 def obj @obj end |
#priority ⇒ Object
Returns the value of attribute priority
88 89 90 |
# File 'lib/edamame/job.rb', line 88 def priority @priority end |
#scheduling ⇒ Object
Returns the value of attribute scheduling
88 89 90 |
# File 'lib/edamame/job.rb', line 88 def scheduling @scheduling end |
#state ⇒ Object
Returns the value of attribute state
88 89 90 |
# File 'lib/edamame/job.rb', line 88 def state @state end |
#ttr ⇒ Object
Returns the value of attribute ttr
88 89 90 |
# File 'lib/edamame/job.rb', line 88 def ttr @ttr end |
#tube ⇒ Object
Returns the value of attribute tube
88 89 90 |
# File 'lib/edamame/job.rb', line 88 def tube @tube end |
Instance Method Details
#delay ⇒ Object
117 118 119 |
# File 'lib/edamame/job.rb', line 117 def delay scheduling.delay end |
#to_hash(flatten = true) ⇒ Object
121 122 123 124 125 126 127 128 129 130 |
# File 'lib/edamame/job.rb', line 121 def to_hash flatten=true hsh = super() hsh["scheduling"] = scheduling.to_hash hsh["obj"] = obj.to_hash if flatten hsh["scheduling"] = hsh['scheduling'].to_yaml hsh["obj"] = hsh['obj'].to_yaml end hsh end |