Class: TwirpRails::ErrorHandlingFactory::HandlerProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/twirp_rails/error_handling/error_handling_factory.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(handler, translator_class) ⇒ HandlerProxy

Returns a new instance of HandlerProxy.



6
7
8
9
# File 'lib/twirp_rails/error_handling/error_handling_factory.rb', line 6

def initialize(handler, translator_class)
  @handler = handler
  @translator_class = translator_class
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object

rubocop:disable Style/MethodMissingSuper



12
13
14
15
16
# File 'lib/twirp_rails/error_handling/error_handling_factory.rb', line 12

def method_missing(method, *args)
  handler.public_send method, *args
rescue => e
  translator_class.exception_to_twirp(e, handler)
end

Instance Attribute Details

#handlerObject (readonly)

Returns the value of attribute handler.



4
5
6
# File 'lib/twirp_rails/error_handling/error_handling_factory.rb', line 4

def handler
  @handler
end

#translator_classObject (readonly)

Returns the value of attribute translator_class.



4
5
6
# File 'lib/twirp_rails/error_handling/error_handling_factory.rb', line 4

def translator_class
  @translator_class
end

Instance Method Details

#respond_to_missing?(method, include_all = false) ⇒ Boolean

rubocop:enable Style/MethodMissingSuper

Returns:

  • (Boolean)


19
20
21
# File 'lib/twirp_rails/error_handling/error_handling_factory.rb', line 19

def respond_to_missing?(method, include_all = false)
  handler.respond_to?(method, include_all)
end