Method: Interlock::Finders::ClassMethods#find

Defined in:
lib/interlock/finders.rb

#find(*args) ⇒ Object

Cached find.

Any other options besides ids short-circuit the cache.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/interlock/finders.rb', line 20

def find(*args)
  return find_via_db(*args) if args.last.is_a? Hash or args.first.is_a? Symbol
  ids = args.flatten.compact.uniq
  return find_via_db(ids) if ids.blank? 

  records = find_via_cache(ids, true)

  if ids.length > 1 or args.first.is_a?(Array)
    records
  else
    records.first
  end      

end