module SBF::Client::Entities::Cacheable::ClassMethods
Public Instance Methods
cache_id(proc)
click to toggle source
# File lib/stbaldricks/entities/lib/cacheable.rb, line 17 def cache_id(proc) define_method(:cache_id) do instance_exec(&proc) end end
cache_id_from_hash(proc_or_hash)
click to toggle source
# 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
Private Instance Methods
cache_id_from_hash_func(proc)
click to toggle source
# File lib/stbaldricks/entities/lib/cacheable.rb, line 34 def cache_id_from_hash_func(proc) raise ArgumentError, "Unable to re-set cache_id_from_hash on #{name}" if @cache_id_proc @cache_id_proc = proc end