Class: Cocupu::Identity
- Inherits:
-
Object
- Object
- Cocupu::Identity
- Defined in:
- lib/cocupu/identity.rb
Instance Attribute Summary collapse
-
#conn ⇒ Object
Returns the value of attribute conn.
-
#values ⇒ Object
Returns the value of attribute values.
Instance Method Summary collapse
-
#initialize(values) ⇒ Identity
constructor
A new instance of Identity.
- #pool(short_name) ⇒ Object
- #pools ⇒ Object
- #short_name ⇒ Object
- #url ⇒ Object
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
#conn ⇒ Object
Returns the value of attribute conn.
3 4 5 |
# File 'lib/cocupu/identity.rb', line 3 def conn @conn end |
#values ⇒ Object
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 |
#pools ⇒ Object
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_name ⇒ Object
9 10 11 |
# File 'lib/cocupu/identity.rb', line 9 def short_name values["short_name"] end |
#url ⇒ Object
13 14 15 |
# File 'lib/cocupu/identity.rb', line 13 def url values["url"] end |