Class: Cocupu::Identity

Inherits:
Object
  • Object
show all
Defined in:
lib/cocupu/identity.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(values) ⇒ Identity

Returns a new instance of Identity.



4
5
6
7
# File 'lib/cocupu/identity.rb', line 4

def initialize(values)
  self.conn = Thread.current[:cocupu_connection] 
  self.values = values
end

Instance Attribute Details

#connObject

Returns the value of attribute conn.



3
4
5
# File 'lib/cocupu/identity.rb', line 3

def conn
  @conn
end

#valuesObject

Returns the value of attribute values.



3
4
5
# File 'lib/cocupu/identity.rb', line 3

def values
  @values
end

Instance Method Details

#pool(short_name) ⇒ Object



24
25
26
# File 'lib/cocupu/identity.rb', line 24

def pool(short_name)
  pools.find{|i| i.short_name == short_name}
end

#poolsObject



17
18
19
20
21
22
# File 'lib/cocupu/identity.rb', line 17

def pools
  return @pools if @pools
  response = conn.get(url+'.json')
  raise "Error getting pools: #{response}" unless response.code == 200
  @pools = response.map {|val| Pool.new(val, conn)}
end

#short_nameObject



9
10
11
# File 'lib/cocupu/identity.rb', line 9

def short_name
  values["short_name"]
end

#urlObject



13
14
15
# File 'lib/cocupu/identity.rb', line 13

def url
  values["url"]
end