class ATSD::ATSD
Main class which holds REST client and resource services.
Attributes
client[R]
@return [Client] REST API client
Public Class Methods
new(options, &block)
click to toggle source
@option options [String] :url API Endpoint @option options [Hash{Symbol => String}, String] :basic_auth A string 'login:password'
or hash with :login and :password keys
@option options [Boolean, Logger] :logger `true` to use default logger, false to disable logging
or a custom logger
@yield [Faraday::Connection] Modify middleware in the block @see www.rubydoc.info/gems/faraday/0.9.1/Faraday/Connection:initialize for other options
# File lib/atsd/atsd.rb, line 24 def initialize(options, &block) @client = Client.new(options, &block) end
service(name, type)
click to toggle source
Defines a new lazy-loaded service @param [Symbol] name the service name @param [Class] type the service's type @!macro [attach] service
@return [$2] the $1 service
# File lib/atsd/atsd.rb, line 34 def service(name, type) define_method(name) do var_name = "@#{name}" if instance_variable_defined? var_name instance_variable_get var_name else obj = type.new instance_variable_get('@client') instance_variable_set var_name, obj obj end end end