Class: Controll::Flow::Master
- Inherits:
-
Object
- Object
- Controll::Flow::Master
show all
- Includes:
- Macros
- Defined in:
- lib/controll/flow/master.rb,
lib/controll/flow/master/macros.rb,
lib/controll/flow/master/executor.rb
Defined Under Namespace
Modules: Macros
Classes: Executor
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(controller, options = {}) ⇒ Master
Returns a new instance of Master.
10
11
12
13
|
# File 'lib/controll/flow/master.rb', line 10
def initialize controller, options = {}
@controller = controller
@options = options
end
|
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
8
9
10
|
# File 'lib/controll/flow/master.rb', line 8
def action
@action
end
|
#controller ⇒ Object
Returns the value of attribute controller.
8
9
10
|
# File 'lib/controll/flow/master.rb', line 8
def controller
@controller
end
|
#options ⇒ Object
Returns the value of attribute options.
8
9
10
|
# File 'lib/controll/flow/master.rb', line 8
def options
@options
end
|
Class Method Details
.action_handlers ⇒ Object
35
36
37
|
# File 'lib/controll/flow/master.rb', line 35
def action_handlers
@action_handlers ||= []
end
|
.add_action_handler(name) ⇒ Object
39
40
41
42
|
# File 'lib/controll/flow/master.rb', line 39
def add_action_handler name
@action_handlers ||= []
@action_handlers << name.to_s.underscore.to_sym
end
|
.mapper_types ⇒ Object
53
54
55
|
# File 'lib/controll/flow/master.rb', line 53
def mapper_types
[:simple, :complex]
end
|
.valid_handler?(handler_type) ⇒ Boolean
44
45
46
47
|
# File 'lib/controll/flow/master.rb', line 44
def valid_handler? handler_type
raise ArgumentError, "Must be a String or Symbol, was: #{handler_type}" if handler_type.blank?
valid_handlers.include? handler_type.to_sym
end
|
.valid_handlers ⇒ Object
49
50
51
|
# File 'lib/controll/flow/master.rb', line 49
def valid_handlers
[:renderer, :redirecter]
end
|
Instance Method Details
#execute ⇒ Object
Uses Executor to execute each registered ActionHandler, such ad Renderer and Redirecter The first ActionHandler matching the event returns an appropriate Action In case no ActionHandler matches, the Fallback action is returned
18
19
20
21
22
|
# File 'lib/controll/flow/master.rb', line 18
def execute
@action = executor.execute || fallback
@action.set_errors errors
@action
end
|
#executor ⇒ Object
24
25
26
|
# File 'lib/controll/flow/master.rb', line 24
def executor
@executor ||= Executor.new controller, executor_options
end
|
#executor_options ⇒ Object
28
29
30
|
# File 'lib/controll/flow/master.rb', line 28
def executor_options
{event: event, action_handlers: action_handlers}
end
|