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
254 def cache_get_pk(pk)
255   primary_key_lookup(pk)
256 end
first(*args) { || ... } click to toggle source

Use static cache to return first arguments.

Calls superclass method
    # File lib/sequel/plugins/static_cache.rb
259 def first(*args)
260   if !defined?(yield) && args.empty?
261     if o = @all.first
262       _static_cache_frozen_copy(o)
263     end
264   else
265     super
266   end
267 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
273 def _static_cache_frozen_copy(o)
274   o = call(Hash[o.values])
275   o.errors.freeze
276   o.freeze
277 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
280 def primary_key_lookup(pk)
281   if o = cache[pk]
282     _static_cache_frozen_copy(o)
283   end
284 end