23
24
25
26
27
28
29
30
31
32
|
# File 'lib/stbaldricks/entities/lib/cacheable.rb', line 23
def cache_id_from_hash(proc_or_hash)
return cache_id_from_hash_func(proc_or_hash) if proc_or_hash.is_a?(Proc)
raise CacheableNotImplementedError unless @cache_id_proc || superclass.respond_to?(:cache_id_from_hash)
id = @cache_id_proc.call(proc_or_hash || {}) if @cache_id_proc
id ||= superclass.cache_id_from_hash(proc_or_hash || {}) if superclass.respond_to?(:cache_id_from_hash)
raise CacheableInvalidDataError, "Data missing id. Data: #{proc_or_hash.to_json}" unless id
id
end
|