module Sequel::Plugins::StaticCache::ForbidLazyLoadClassMethods

Public Instance Methods

cache_get_pk(pk) click to toggle source

Do not forbid lazy loading for single object retrieval.

    # File lib/sequel/plugins/static_cache.rb
267 def cache_get_pk(pk)
268   primary_key_lookup(pk)
269 end
first(*args) { || ... } click to toggle source

Use static cache to return first arguments.

Calls superclass method
    # File lib/sequel/plugins/static_cache.rb
272 def first(*args)
273   if !defined?(yield) && args.empty?
274     if o = @all.first
275       _static_cache_frozen_copy(o)
276     end
277   else
278     super
279   end
280 end

Private Instance Methods

_static_cache_frozen_copy(o) click to toggle source

Return a frozen copy of the object that does not have lazy loading forbidden.

    # File lib/sequel/plugins/static_cache.rb
286 def _static_cache_frozen_copy(o)
287   o = call(Hash[o.values])
288   o.errors.freeze
289   o.freeze
290 end
primary_key_lookup(pk) click to toggle source

Do not forbid lazy loading for single object retrieval.

    # File lib/sequel/plugins/static_cache.rb
293 def primary_key_lookup(pk)
294   if o = cache[pk]
295     _static_cache_frozen_copy(o)
296   end
297 end