Class: Relaxo::Connection
- Inherits:
-
Object
- Object
- Relaxo::Connection
- Defined in:
- lib/relaxo/connection.rb
Constant Summary collapse
- DEFAULT_UUID_FETCH_COUNT =
10
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #fetch_uuids(count) ⇒ Object
- #info ⇒ Object
-
#initialize(url) ⇒ Connection
constructor
A new instance of Connection.
- #next_uuid ⇒ Object
Constructor Details
#initialize(url) ⇒ Connection
Returns a new instance of Connection.
27 28 29 30 |
# File 'lib/relaxo/connection.rb', line 27 def initialize(url) @url = url @uuids = [] end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
32 33 34 |
# File 'lib/relaxo/connection.rb', line 32 def url @url end |
Instance Method Details
#fetch_uuids(count) ⇒ Object
34 35 36 |
# File 'lib/relaxo/connection.rb', line 34 def fetch_uuids(count) @uuids += Client.get("#{@url}/_uuids?count=#{count}")["uuids"] end |
#next_uuid ⇒ Object
38 39 40 41 42 |
# File 'lib/relaxo/connection.rb', line 38 def next_uuid fetch_uuids(DEFAULT_UUID_FETCH_COUNT) if @uuids.size == 0 @uuids.pop end |