class Pleiades::Client::Wrapper

Attributes

histories[R]

Public Class Methods

new(client) click to toggle source
# File lib/pleiades/core/client/wrapper.rb, line 6
def initialize(client)
  @obj = client
  @histories = []
end

Private Instance Methods

execute(method, *args) click to toggle source
# File lib/pleiades/core/client/wrapper.rb, line 27
def execute(method, *args)
  res = @obj.__send__ method, *args
  code = res.code
  body = JSON.parse(res.body)

  @histories << response.new(method, code, body)

  [code, body]
end
method_assigns(method, *args) click to toggle source
# File lib/pleiades/core/client/wrapper.rb, line 37
def method_assigns(method, *args)
  return {} if args.empty?

  @obj.method(method)
      .parameters
      .map(&:last)
      .each_with_index
      .each_with_object({}) do |(arg_name, at), hash|
        hash.store(arg_name, args[at])
      end
end
method_missing(method, *args, &block) click to toggle source
Calls superclass method
# File lib/pleiades/core/client/wrapper.rb, line 13
def method_missing(method, *args, &block)
  return super unless @obj.respond_to?(method)

  execute(method, *args)
end
respond_to?(method) click to toggle source
Calls superclass method
# File lib/pleiades/core/client/wrapper.rb, line 23
def respond_to?(method)
  @obj.respond_to?(method) || super
end
respond_to_missing?(method, *_, &_) click to toggle source
Calls superclass method
# File lib/pleiades/core/client/wrapper.rb, line 19
def respond_to_missing?(method, *_, &_)
  @obj.respond_to?(method) || super
end
response() click to toggle source
# File lib/pleiades/core/client/wrapper.rb, line 49
def response
  attributes = %i[method_name code body]
  Struct.new(*attributes)
end