class IOSTSdk::Http::Client
Constants
- METHODS
- READ_METHODS
key: method name value: an array of args
- WRITE_METHODS
Public Class Methods
new(base_url:)
click to toggle source
# File lib/iost_sdk/http/client.rb, line 43 def initialize(base_url:) @base_url = base_url METHODS.each do |method_name, method_args| # require the file require "iost_sdk/http/#{method_name}" # define the method self.class.send(:define_method, method_name) do |**args| # extract match args for the call raise ArgumentError.new('Invalid method arguments.') unless Set.new(method_args).subset?(Set.new(args.keys)) valid_args = method_args.reduce({}) do |memo, k| memo[k] = args[k] memo end # init and invoke class_name = IOSTSdk::String.camelize(method_name) clazz = IOSTSdk::String.classify("IOSTSdk::Http::#{class_name}") clazz.new.invoke(valid_args.merge(base_url: @base_url)) end end end
read_apis()
click to toggle source
# File lib/iost_sdk/http/client.rb, line 39 def self.read_apis READ_METHODS end