Class: CFoundry::BaseClient

Inherits:
Object
  • Object
show all
Defined in:
lib/cfoundry/baseclient.rb

Overview

:nodoc:

Direct Known Subclasses

Client, UAAClient, V1::Base, V2::Base

Constant Summary collapse

LOG_LENGTH =
10

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target, token = nil) ⇒ BaseClient

Returns a new instance of BaseClient.



12
13
14
15
16
17
18
# File 'lib/cfoundry/baseclient.rb', line 12

def initialize(target, token = nil)
  @target = target
  @token = token
  @trace = false
  @backtrace = false
  @log = false
end

Instance Attribute Details

#backtraceObject

Returns the value of attribute backtrace.



10
11
12
# File 'lib/cfoundry/baseclient.rb', line 10

def backtrace
  @backtrace
end

#logObject

Returns the value of attribute log.



10
11
12
# File 'lib/cfoundry/baseclient.rb', line 10

def log
  @log
end

#traceObject

Returns the value of attribute trace.



10
11
12
# File 'lib/cfoundry/baseclient.rb', line 10

def trace
  @trace
end

Instance Method Details

#request_path(method, path, options = {}) ⇒ Object



20
21
22
23
24
# File 'lib/cfoundry/baseclient.rb', line 20

def request_path(method, path, options = {})
  path = url(path) if path.is_a?(Array)

  request(method, path, options)
end

#token_dataObject

grab the metadata from a token that looks like:

bearer (base64 …)



29
30
31
32
33
34
35
36
37
38
# File 'lib/cfoundry/baseclient.rb', line 29

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