Sha256: d5149aa118dc869e67a559987eee88cb278f58e77c319883fbea9b44685199ec
Contents?: true
Size: 605 Bytes
Versions: 2
Compression:
Stored size: 605 Bytes
Contents
module Cache module Object class InstanceDecorator < Struct.new(:instance, :mappings) def keys [canonical_cache_key] + mapping_cache_keys end private def mapping_cache_keys mappings.map do |mapping| attributes = mapping.inject({}) do |memo, attr| memo[attr] = instance.send(attr) memo end KeyGenerator.key_for_mapping(instance.class.name, attributes) end end def canonical_cache_key KeyGenerator.key_for_object(instance.class.name, instance.id) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cache-object-0.0.2 | lib/cache/object/instance_decorator.rb |
cache-object-0.0.1 | lib/cache/object/instance_decorator.rb |