Sha256: 971cb96fd422b852768a2327f55c7371bb620fe282f788fe74293da3664bf212
Contents?: true
Size: 622 Bytes
Versions: 6
Compression:
Stored size: 622 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 = {}.tap do |obj| mapping.each { |attr| obj[attr] = instance.send(attr) } end KeyGenerator.key_for_mapping(instance.class.name, attributes) end end def canonical_cache_key KeyGenerator.key_for_object(instance.class.name, instance.send(instance.class.primary_key)) end end end end
Version data entries
6 entries across 6 versions & 1 rubygems