Class: Flareshow::CacheManager
- Inherits:
-
Object
- Object
- Flareshow::CacheManager
- Defined in:
- lib/cache.rb
Overview
provides an interface for various caches that flareshow might use
Class Method Summary collapse
-
.assimilate_resources(data) ⇒ Object
assimilate the resources provided in the response.
-
.cache ⇒ Object
get the managed cache object.
Class Method Details
.assimilate_resources(data) ⇒ Object
assimilate the resources provided in the response
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/cache.rb', line 7 def assimilate_resources(data) # process each resource key and generate a new object # or merge the object data with an existing object data.inject({}) do |memo,resource_pair| resource_key, resources = resource_pair[0], resource_pair[1] fs_resource_array = memo[resource_key] ||= [] klass = Kernel.const_get(Flareshow::ResourceToClassMap[resource_key]) if klass resources.each do |resource_data| item = cache.get_resource(resource_key, resource_data["id"]) if item item.update(resource_data, :server) else item = klass.new(resource_data, :server) end cache.set_resource(resource_key, item.id, item) fs_resource_array << item end end memo end end |