Method: Sequel::Plugins::StaticCache::ClassMethods#first

Defined in:
lib/sequel/plugins/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).



92
93
94
95
96
97
98
# File 'lib/sequel/plugins/static_cache.rb', line 92

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