Class: TwirpRails::ErrorHandlingFactory::HandlerProxy
- Inherits:
-
Object
- Object
- TwirpRails::ErrorHandlingFactory::HandlerProxy
- Defined in:
- lib/twirp_rails/error_handling/error_handling_factory.rb
Instance Attribute Summary collapse
-
#handler ⇒ Object
readonly
Returns the value of attribute handler.
-
#translator_class ⇒ Object
readonly
Returns the value of attribute translator_class.
Instance Method Summary collapse
-
#initialize(handler, translator_class) ⇒ HandlerProxy
constructor
A new instance of HandlerProxy.
-
#method_missing(method, *args) ⇒ Object
rubocop:disable Style/MethodMissingSuper.
-
#respond_to_missing?(method, include_all = false) ⇒ Boolean
rubocop:enable Style/MethodMissingSuper.
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
#handler ⇒ Object (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_class ⇒ Object (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
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 |