module Plangrade::Configurable
Attributes
access_token[RW]
client_id[RW]
client_secret[RW]
connection_options[RW]
default_headers[RW]
http_adapter[RW]
site_url[RW]
Public Class Methods
default_options()
click to toggle source
Return a hash with the default options @return [Hash]
# File lib/plangrade/configurable.rb, line 14 def self.default_options { :site_url => ENDPOINT, :client_id => ENV['PLANGRADE_CLIENT_ID'], :client_secret => ENV['PLANGRADE_CLIENT_SECRET'], :access_token => ENV['PLANGRADE_ACCESS_TOKEN'], :http_adapter => HTTP_ADAPTER, :connection_options => { :max_redirects => 5, :verify_ssl => true }, :default_headers => { 'Accept' => 'application/json', 'User-Agent' => "Plangrade Ruby Gem #{Plangrade::Ruby::VERSION}" } } end
keys()
click to toggle source
@return [Array<String>]
# File lib/plangrade/configurable.rb, line 30 def self.keys self.default_options.keys end
Public Instance Methods
configure() { |self| ... }
click to toggle source
Convenience method to allow configuration options to be set in a block
# File lib/plangrade/configurable.rb, line 47 def configure yield self if block_given? self end
disable_logging()
click to toggle source
# File lib/plangrade/configurable.rb, line 56 def disable_logging self.http_adapter.log = nil end
enable_logging(output='stdout')
click to toggle source
# File lib/plangrade/configurable.rb, line 52 def enable_logging(output='stdout') self.http_adapter.log = output end
options()
click to toggle source
@return [Hash]
# File lib/plangrade/configurable.rb, line 35 def options Hash[Plangrade::Configurable.keys.map{|key| [key, instance_variable_get(:"@#{key}")]}] end
reset!()
click to toggle source
# File lib/plangrade/configurable.rb, line 39 def reset! Plangrade::Configurable.keys.each do |key| instance_variable_set(:"@#{key}", Plangrade::Configurable.default_options[key.to_sym]) end self end
with_logging(output) { |self| ... }
click to toggle source
# File lib/plangrade/configurable.rb, line 60 def with_logging(output) cached_output = self.http_adapter.log enable_logging(output) yield self if block_given? self.http_adapter.log = cached_output end