Class: PerfectSched::Application::Base
- Defined in:
- lib/perfectsched/application/base.rb
Instance Attribute Summary collapse
-
#decider ⇒ Object
readonly
Returns the value of attribute decider.
Attributes inherited from Runner
Class Method Summary collapse
Instance Method Summary collapse
-
#after_perform ⇒ Object
def perform end.
- #before_perform ⇒ Object
- #decide!(type, option = {}) ⇒ Object
-
#initialize(task) ⇒ Base
constructor
A new instance of Base.
- #run ⇒ Object
Methods inherited from Runner
Constructor Details
#initialize(task) ⇒ Base
Returns a new instance of Base.
34 35 36 37 |
# File 'lib/perfectsched/application/base.rb', line 34 def initialize(task) super @decider = self.class.decider.new(self) end |
Instance Attribute Details
#decider ⇒ Object (readonly)
Returns the value of attribute decider.
39 40 41 |
# File 'lib/perfectsched/application/base.rb', line 39 def decider @decider end |
Class Method Details
.decider ⇒ Object
23 24 25 |
# File 'lib/perfectsched/application/base.rb', line 23 def self.decider DefaultDecider end |
.decider=(decider_klass) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/perfectsched/application/base.rb', line 27 def self.decider=(decider_klass) (class<<self;self;end).instance_eval do self.__send__(:define_method, :decider) { decider_klass } end decider_klass end |
Instance Method Details
#after_perform ⇒ Object
def perform end
61 62 |
# File 'lib/perfectsched/application/base.rb', line 61 def after_perform end |
#before_perform ⇒ Object
54 55 56 |
# File 'lib/perfectsched/application/base.rb', line 54 def before_perform true end |
#decide!(type, option = {}) ⇒ Object
64 65 66 |
# File 'lib/perfectsched/application/base.rb', line 64 def decide!(type, option={}) @decider.decide!(type, option) end |
#run ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/perfectsched/application/base.rb', line 41 def run begin return unless before_perform begin perform ensure after_perform end rescue decide! :unexpected_error_raised, :error=>$! end end |