Method: Sequel::Plugins::SubsetStaticCache::CachedDatasetMethods#first

Defined in:
lib/sequel/plugins/subset_static_cache.rb

#first(*args) ⇒ Object

If a block is given, multiple arguments are given, or a single non-Integer argument is given, performs the default behavior of issuing a database query. Otherwise, uses the cached values to return either the first cached instance (no arguments) or an array containing the number of instances specified (single integer argument).

[View source]

154
155
156
157
158
159
160
# File 'lib/sequel/plugins/subset_static_cache.rb', line 154

def first(*args)
  if !defined?(yield) && args.length <= 1 && (args.length == 0 || args[0].is_a?(Integer)) && (all = @cache[:subset_static_cache_all])
    all.first(*args)
  else
    super
  end
end