class Controll::Flow::Master
Attributes
action[R]
controller[R]
options[R]
Public Class Methods
action_handlers()
click to toggle source
# File lib/controll/flow/master.rb, line 35 def action_handlers @action_handlers ||= [] end
add_action_handler(name)
click to toggle source
# 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()
click to toggle source
# File lib/controll/flow/master.rb, line 53 def mapper_types [:simple, :complex] end
new(controller, options = {})
click to toggle source
# File lib/controll/flow/master.rb, line 10 def initialize controller, options = {} @controller = controller @options = options end
valid_handler?(handler_type)
click to toggle source
# 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()
click to toggle source
# File lib/controll/flow/master.rb, line 49 def valid_handlers [:renderer, :redirecter] end
Public Instance Methods
execute()
click to toggle source
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
# File lib/controll/flow/master.rb, line 18 def execute @action = executor.execute || fallback @action.set_errors errors @action end
executor()
click to toggle source
# File lib/controll/flow/master.rb, line 24 def executor @executor ||= Executor.new controller, executor_options end
executor_options()
click to toggle source
# File lib/controll/flow/master.rb, line 28 def executor_options {event: event, action_handlers: action_handlers} end
Protected Instance Methods
action_handlers()
click to toggle source
# File lib/controll/flow/master.rb, line 62 def action_handlers self.class.action_handlers end
event()
click to toggle source
# File lib/controll/flow/master.rb, line 66 def event raise Controll::Flow::EventNotImplementedError, 'You must define an #event method that returns an event (or Symbol). You can use an Executor for this.' end