Class: CFoundry::BaseClient
- Inherits:
-
Object
- Object
- CFoundry::BaseClient
- Defined in:
- lib/cfoundry/baseclient.rb
Overview
:nodoc:
Constant Summary collapse
- LOG_LENGTH =
10
Instance Attribute Summary collapse
-
#backtrace ⇒ Object
Returns the value of attribute backtrace.
-
#log ⇒ Object
Returns the value of attribute log.
-
#trace ⇒ Object
Returns the value of attribute trace.
Instance Method Summary collapse
-
#initialize(target, token = nil) ⇒ BaseClient
constructor
A new instance of BaseClient.
- #request_path(method, path, types = {}, options = {}) ⇒ Object
-
#token_data ⇒ Object
grab the metadata from a token that looks like:.
Constructor Details
#initialize(target, token = nil) ⇒ BaseClient
Returns a new instance of BaseClient.
11 12 13 14 15 16 17 |
# File 'lib/cfoundry/baseclient.rb', line 11 def initialize(target, token = nil) @target = target @token = token @trace = false @backtrace = false @log = false end |
Instance Attribute Details
#backtrace ⇒ Object
Returns the value of attribute backtrace.
9 10 11 |
# File 'lib/cfoundry/baseclient.rb', line 9 def backtrace @backtrace end |
#log ⇒ Object
Returns the value of attribute log.
9 10 11 |
# File 'lib/cfoundry/baseclient.rb', line 9 def log @log end |
#trace ⇒ Object
Returns the value of attribute trace.
9 10 11 |
# File 'lib/cfoundry/baseclient.rb', line 9 def trace @trace end |
Instance Method Details
#request_path(method, path, types = {}, options = {}) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/cfoundry/baseclient.rb', line 19 def request_path(method, path, types = {}, = {}) path = url(path) if path.is_a?(Array) unless types.empty? if params = types.delete(:params) [:params] = params end if types.size > 1 raise "request types must contain only one Content-Type => Accept" end [:type] = types.keys.first [:accept] = types.values.first end request(method, path, ) end |
#token_data ⇒ Object
grab the metadata from a token that looks like:
bearer (base64 …)
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/cfoundry/baseclient.rb', line 41 def token_data tok = Base64.decode64(@token.sub(/^bearer\s+/, "")) tok.sub!(/\{.+?\}/, "") # clear algo MultiJson.load(tok[/\{.+?\}/], :symbolize_keys => true) # normally i don't catch'em all, but can't expect all tokens to be the # proper format, so just silently fail as this is not critical rescue {} end |