Class: TronHttp::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/tron_http/config.rb

Overview

Config

Class Method Summary collapse

Class Method Details

.define_endpoint_methodsObject



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/tron_http/config.rb', line 30

def self.define_endpoint_methods
  endpoints.each do |endpoint, options|
    path = options["path"]
    method = options["method"]
    variables = options["variables"]

    Client.define_method(endpoint) do |params = {}|
      Helpers.validate_variables variables, params
      HTTP.send method, URI(@hostname + path), params
    end
  end
end

.define_network_methodsObject



22
23
24
25
26
27
28
# File 'lib/tron_http/config.rb', line 22

def self.define_network_methods
  hostnames.each_key do |network|
    TronHttp.define_singleton_method(network) do
      Client.new network
    end
  end
end

.endpointsObject



13
14
15
# File 'lib/tron_http/config.rb', line 13

def self.endpoints
  TronHttp::DATA["endpoints"]
end

.hostnamesObject



9
10
11
# File 'lib/tron_http/config.rb', line 9

def self.hostnames
  TronHttp::DATA["hostnames"]
end

.scaffoldObject



17
18
19
20
# File 'lib/tron_http/config.rb', line 17

def self.scaffold
  define_network_methods
  define_endpoint_methods
end