module Apiway::Controller::InstanceMethods
Attributes
client[R]
params[R]
Public Class Methods
new( action_name, client, params = {} )
click to toggle source
# File lib/apiway/controller.rb, line 63 def initialize( action_name, client, params = {} ) @action_name = action_name @action = self.class.action @action_name @client = client @params = params end
Public Instance Methods
run()
click to toggle source
# File lib/apiway/controller.rb, line 70 def run begin run_filters :before result = run_action run_filters :after rescue ControllerError => e failure e.params else success result end end
Protected Instance Methods
error( params )
click to toggle source
# File lib/apiway/controller.rb, line 91 def error( params ) raise ControllerError, params end
trigger( *args )
click to toggle source
# File lib/apiway/controller.rb, line 87 def trigger( *args ) add_method_to_call :trigger, args end
Private Instance Methods
add_method_to_call( method, args )
click to toggle source
# File lib/apiway/controller.rb, line 106 def add_method_to_call( method, args ) Thread.current[ :methods_to_call ] << [ method, args ] end
failure( *args )
click to toggle source
# File lib/apiway/controller.rb, line 114 def failure( *args ) add_method_to_call :failure, args end
run_action()
click to toggle source
# File lib/apiway/controller.rb, line 98 def run_action instance_eval &@action end
run_filters( type )
click to toggle source
# File lib/apiway/controller.rb, line 102 def run_filters( type ) self.class.select_filters( type, @action_name ).each { |method_name, only, except| send method_name } end
success( *args )
click to toggle source
# File lib/apiway/controller.rb, line 110 def success( *args ) add_method_to_call :success, args end