Class: WipeOut::Execution::Context

Inherits:
Object
  • Object
show all
Includes:
Observable
Defined in:
lib/wipe_out/execution/context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(plan, record, config = plan.config) ⇒ Context

Returns a new instance of Context.



9
10
11
12
13
14
15
# File 'lib/wipe_out/execution/context.rb', line 9

def initialize(plan, record, config = plan.config)
  @plan = plan
  @record = record
  @config = config

  add_observer(CallbacksObserver.new(plan.callbacks, self))
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



7
8
9
# File 'lib/wipe_out/execution/context.rb', line 7

def config
  @config
end

#planObject (readonly)

Returns the value of attribute plan.



7
8
9
# File 'lib/wipe_out/execution/context.rb', line 7

def plan
  @plan
end

#recordObject (readonly)

Returns the value of attribute record.



7
8
9
# File 'lib/wipe_out/execution/context.rb', line 7

def record
  @record
end

Instance Method Details

#notify(name) ⇒ Object



23
24
25
26
# File 'lib/wipe_out/execution/context.rb', line 23

def notify(name)
  changed
  notify_observers(name)
end

#runObject



17
18
19
20
21
# File 'lib/wipe_out/execution/context.rb', line 17

def run
  on_execute = plan.on_execute || config.default_on_execute

  on_execute.call(self)
end

#subexecution(sub_plan, record) ⇒ Object



28
29
30
# File 'lib/wipe_out/execution/context.rb', line 28

def subexecution(sub_plan, record)
  self.class.new(sub_plan, record, config)
end