class DoubleMap::API
A base class implementing common API
operations
Public Class Methods
include_api(name)
click to toggle source
Include another API's functionality via a new method on this API
. For example, `include_api :routes` would include the “Routes” API
into the “Client” API
, accessible as `Client#routes`.
# File lib/doublemap_api/api.rb, line 14 def include_api name klass = self.const_get(name.to_s.constantize) define_method(name) do klass.new end self.memoize name end
require_all(folder, *libs)
click to toggle source
Require all the files given in `names` that exist in the given folder
# File lib/doublemap_api/api.rb, line 23 def require_all folder, *libs libs.each do |lib| require_relative "#{File.join(folder, lib)}" end end
singleton()
click to toggle source
Return a singleton instance of this API
# File lib/doublemap_api/api.rb, line 30 def singleton @singleton ||= self.new end
Public Instance Methods
get_request(endpoint, opts={})
click to toggle source
Perform a GET request over the connection to the given endpoint.
# File lib/doublemap_api/api.rb, line 37 def get_request endpoint, opts={}, &block connection.get endpoint, opts, &block end
post_request(endpoint, opts={})
click to toggle source
Perform a POST request over the connection to the given endpoint.
# File lib/doublemap_api/api.rb, line 42 def post_request endpoint, opts={}, &block connection.post endpoint, opts, &block end
refresh()
click to toggle source
For APIs that extend Memoist, allow the user to call `refresh` as an alias for `flush_cache`.
# File lib/doublemap_api/api.rb, line 48 def refresh send(:flush_cache) if respond_to?(:flush_cache) end