Class: ZaifWrapper::Client::ZaifFutureApi

Inherits:
ZaifParentApi show all
Defined in:
lib/zaif_wrapper/client.rb

Constant Summary

Constants inherited from ZaifParentApi

ZaifWrapper::Client::ZaifParentApi::FUTURE_METHODS, ZaifWrapper::Client::ZaifParentApi::FUTURE_REQUEST_URL_BASE, ZaifWrapper::Client::ZaifParentApi::LEVERAGE_METHODS, ZaifWrapper::Client::ZaifParentApi::LEVERAGE_REQUEST_URL_BASE, ZaifWrapper::Client::ZaifParentApi::PRIVATE_METHODS, ZaifWrapper::Client::ZaifParentApi::PRIVATE_REQUEST_URL_BASE, ZaifWrapper::Client::ZaifParentApi::PUBLIC_METHODS, ZaifWrapper::Client::ZaifParentApi::PUBLIC_REQUEST_URL_BASE

Instance Method Summary collapse

Methods inherited from ZaifParentApi

#create_signature, #get_nonce, #get_request, #post_request

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/zaif_wrapper/client.rb', line 106

def method_missing(name, *args)
  if FUTURE_METHODS.include?(name.to_s)
    klass = class << self; self end
    klass.class_eval do
      define_method(name) do |body = []|
        path = name
        if body.length != 0
          body.each do |param|
            path = path + "/#{param}"
          end
        end
        get_request(FUTURE_REQUEST_URL_BASE, path)
      end
    end
    if args.length == 1
      __send__(name, args[0])
    else
      __send__(name)
    end
  end
end