Module: Plangrade::Configurable
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#client_id ⇒ Object
Returns the value of attribute client_id.
-
#client_secret ⇒ Object
Returns the value of attribute client_secret.
-
#connection_options ⇒ Object
Returns the value of attribute connection_options.
-
#default_headers ⇒ Object
Returns the value of attribute default_headers.
-
#http_adapter ⇒ Object
Returns the value of attribute http_adapter.
-
#site_url ⇒ Object
Returns the value of attribute site_url.
Class Method Summary collapse
-
.default_options ⇒ Hash
Return a hash with the default options.
- .keys ⇒ Array<String>
Instance Method Summary collapse
-
#configure {|_self| ... } ⇒ Object
Convenience method to allow configuration options to be set in a block.
- #disable_logging ⇒ Object
- #enable_logging(output = 'stdout') ⇒ Object
- #options ⇒ Hash
- #reset! ⇒ Object
- #with_logging(output) {|_self| ... } ⇒ Object
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
9 10 11 |
# File 'lib/plangrade/configurable.rb', line 9 def access_token @access_token end |
#client_id ⇒ Object
Returns the value of attribute client_id.
9 10 11 |
# File 'lib/plangrade/configurable.rb', line 9 def client_id @client_id end |
#client_secret ⇒ Object
Returns the value of attribute client_secret.
9 10 11 |
# File 'lib/plangrade/configurable.rb', line 9 def client_secret @client_secret end |
#connection_options ⇒ Object
Returns the value of attribute connection_options.
9 10 11 |
# File 'lib/plangrade/configurable.rb', line 9 def end |
#default_headers ⇒ Object
Returns the value of attribute default_headers.
9 10 11 |
# File 'lib/plangrade/configurable.rb', line 9 def default_headers @default_headers end |
#http_adapter ⇒ Object
Returns the value of attribute http_adapter.
9 10 11 |
# File 'lib/plangrade/configurable.rb', line 9 def http_adapter @http_adapter end |
#site_url ⇒ Object
Returns the value of attribute site_url.
9 10 11 |
# File 'lib/plangrade/configurable.rb', line 9 def site_url @site_url end |
Class Method Details
.default_options ⇒ Hash
Return a hash with the default options
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/plangrade/configurable.rb', line 14 def self. { :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 ⇒ Array<String>
30 31 32 |
# File 'lib/plangrade/configurable.rb', line 30 def self.keys self..keys end |
Instance Method Details
#configure {|_self| ... } ⇒ Object
Convenience method to allow configuration options to be set in a block
47 48 49 50 |
# File 'lib/plangrade/configurable.rb', line 47 def configure yield self if block_given? self end |
#disable_logging ⇒ Object
56 57 58 |
# File 'lib/plangrade/configurable.rb', line 56 def disable_logging self.http_adapter.log = nil end |
#enable_logging(output = 'stdout') ⇒ Object
52 53 54 |
# File 'lib/plangrade/configurable.rb', line 52 def enable_logging(output='stdout') self.http_adapter.log = output end |
#options ⇒ Hash
35 36 37 |
# File 'lib/plangrade/configurable.rb', line 35 def Hash[Plangrade::Configurable.keys.map{|key| [key, instance_variable_get(:"@#{key}")]}] end |
#reset! ⇒ Object
39 40 41 42 43 44 |
# File 'lib/plangrade/configurable.rb', line 39 def reset! Plangrade::Configurable.keys.each do |key| instance_variable_set(:"@#{key}", Plangrade::Configurable.[key.to_sym]) end self end |
#with_logging(output) {|_self| ... } ⇒ Object
60 61 62 63 64 65 |
# 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 |