Class: Twirp::Rails::Handler

Inherits:
Object
  • Object
show all
Includes:
ActiveSupport::Rescuable, Callbacks
Defined in:
lib/twirp/rails/handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#action_nameObject (readonly)

Returns the value of attribute action_name.



11
12
13
# File 'lib/twirp/rails/handler.rb', line 11

def action_name
  @action_name
end

#envObject (readonly)

Returns the value of attribute env.



10
11
12
# File 'lib/twirp/rails/handler.rb', line 10

def env
  @env
end

#errorObject

Returns the value of attribute error.



12
13
14
# File 'lib/twirp/rails/handler.rb', line 12

def error
  @error
end

#requestObject (readonly)

Returns the value of attribute request.



10
11
12
# File 'lib/twirp/rails/handler.rb', line 10

def request
  @request
end

Instance Method Details

#process(name, request, env) ⇒ Object

Parameters:

  • name (Symbol)

    The method name to invoke in the handler

  • request (Object)

    The protobuf message request parameter

  • env (Hash)

    The Twirp environment



17
18
19
20
21
22
23
24
25
# File 'lib/twirp/rails/handler.rb', line 17

def process(name, request, env)
  @request = request
  @env = env
  @error = nil
  @action_name = name.to_s

  response = process_action(action_name)
  error || response
end