Class: IronCache::Caches
- Inherits:
-
Object
- Object
- IronCache::Caches
- Defined in:
- lib/iron_cache/caches.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
Instance Method Summary collapse
-
#get(options = {}) ⇒ Object
options: :name => can specify an alternative queue name.
-
#initialize(client) ⇒ Caches
constructor
A new instance of Caches.
- #list(options = {}) ⇒ Object
- #path(options = {}) ⇒ Object
Constructor Details
#initialize(client) ⇒ Caches
Returns a new instance of Caches.
8 9 10 |
# File 'lib/iron_cache/caches.rb', line 8 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
6 7 8 |
# File 'lib/iron_cache/caches.rb', line 6 def client @client end |
Instance Method Details
#get(options = {}) ⇒ Object
options:
:name => can specify an alternative queue name
36 37 38 39 40 41 42 43 |
# File 'lib/iron_cache/caches.rb', line 36 def get(={}) if .is_a?(String) = {:name=>} end [:name] ||= @client.cache_name res = @client.parse_response(@client.get("#{path()}")) Cache.new(@client, res) end |
#list(options = {}) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/iron_cache/caches.rb', line 20 def list(={}) ret = [] res = @client.get("#{path()}", ) @client.logger.debug res.inspect parsed = @client.parse_response(res, true) @client.logger.debug parsed.inspect parsed.each do |q| @client.logger.debug "cache: " + q.inspect q = Cache.new(@client, q) ret << q end ret end |
#path(options = {}) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/iron_cache/caches.rb', line 12 def path(={}) path = "projects/#{@client.project_id}/caches" if [:name] path << "/#{URI.escape([:name])}" end path end |