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

Use static cache to return first arguments.

Calls superclass method
# File lib/sequel/plugins/static_cache.rb, line 258
def first(*args)
  if !defined?(yield) && args.empty?
    if o = @all.first
      _static_cache_frozen_copy(o)
    end
  else
    super
  end
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, line 272
def _static_cache_frozen_copy(o)
  o = call(Hash[o.values])
  o.errors.freeze
  o.freeze
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, line 279
def primary_key_lookup(pk)
  if o = cache[pk]
    _static_cache_frozen_copy(o)
  end
end