Class: Dynflow::Middleware::World

Inherits:
Object
  • Object
show all
Includes:
Algebrick::TypeCheck
Defined in:
lib/dynflow/middleware/world.rb

Instance Method Summary collapse

Constructor Details

#initializeWorld

Returns a new instance of World.



6
7
8
9
# File 'lib/dynflow/middleware/world.rb', line 6

def initialize
  @register = Middleware::Register.new
  clear_cache!
end

Instance Method Details

#clear_cache!Object



33
34
35
# File 'lib/dynflow/middleware/world.rb', line 33

def clear_cache!
  @middleware_classes_cache = {}
end

#execute(method, action_or_class, *args, &block) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/dynflow/middleware/world.rb', line 16

def execute(method, action_or_class, *args, &block)
  Match! method, :plan, :run, :finalize, :plan_phase, :finalize_phase
  if Child? action_or_class, Dynflow::Action
    action = nil
    action_class = action_or_class
  elsif Type? action_or_class, Dynflow::Action
    action = action_or_class
    action_class = action.class
  else
    Algebrick::TypeCheck.error action_or_class, 'is not instance or child class', Dynflow::Action
  end

  classes = middleware_classes(action_class)
  stack   = Middleware::Stack.build(classes, method, action, &block)
  stack.call(*args)
end

#use(*args) ⇒ Object



11
12
13
14
# File 'lib/dynflow/middleware/world.rb', line 11

def use(*args)
  clear_cache!
  @register.use(*args)
end