Module: Hatt::ApiClients
Constant Summary
Constants included from Configuration
Configuration::DEFAULT_CONFIG_FILE, Configuration::DEFAULT_HATT_GLOBS
Instance Method Summary collapse
-
#hatt_add_service(name, url_or_svc_cfg_hash) ⇒ Object
add a service to hatt.
- #hatt_build_client_methods ⇒ Object
Methods included from Configuration
#hatt_config_file=, #hatt_configuration
Instance Method Details
#hatt_add_service(name, url_or_svc_cfg_hash) ⇒ Object
add a service to hatt
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/hatt/api_clients.rb', line 18 def hatt_add_service(name, url_or_svc_cfg_hash) svc_cfg = case url_or_svc_cfg_hash when String { 'url' => url_or_svc_cfg_hash } when Hash url_or_svc_cfg_hash else raise ArgumentError, "'#{url_or_svc_cfg_hash}' is not a url string nor hash with url key" end init_config services_config = hatt_configuration['hatt_services'] services_config[name] = svc_cfg @hatt_configuration.tcfg_set 'hatt_services', services_config @hatt_http_clients ||= {} @hatt_http_clients[name] = Hatt::HTTP.new hatt_configuration['hatt_services'][name] define_singleton_method name.intern do @hatt_http_clients[name] end end |
#hatt_build_client_methods ⇒ Object
8 9 10 11 12 |
# File 'lib/hatt/api_clients.rb', line 8 def hatt_build_client_methods hatt_configuration[:hatt_services].each_pair do |svc, svc_cfg| hatt_add_service svc, svc_cfg end end |