Class: KOSapiClient::RequestBuilderDelegator

Inherits:
Object
  • Object
show all
Defined in:
lib/kosapi_client/request_builder_delegator.rb

Instance Method Summary collapse

Constructor Details

#initialize(request_builder) ⇒ RequestBuilderDelegator

Returns a new instance of RequestBuilderDelegator.



4
5
6
7
# File 'lib/kosapi_client/request_builder_delegator.rb', line 4

def initialize(request_builder)
  @request_builder = request_builder
  @response = nil
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object

RUBY_VERSION < ‘3.0’



54
55
56
57
58
59
60
# File 'lib/kosapi_client/request_builder_delegator.rb', line 54

def method_missing(method, *args, **kwargs, &block)
  if @response
    delegate_to_response(method, *args, **kwargs, &block)
  else
    delegate_to_builder(method, *args, **kwargs, &block)
  end
end

Instance Method Details

#respond_to_missing?(method, include_all) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
15
16
17
# File 'lib/kosapi_client/request_builder_delegator.rb', line 11

def respond_to_missing?(method, include_all)
  if @response
    @response.respond_to?(method, include_all)
  else
    @request_builder.respond_to?(method, include_all)
  end
end

#super_method_missingObject



9
# File 'lib/kosapi_client/request_builder_delegator.rb', line 9

alias :super_method_missing :method_missing