Module: Searchable

Included in:
Puffs::SQLObject
Defined in:
lib/sql_object/searchable.rb

Overview

Search methods for Puffs::SQLObject

Constant Summary collapse

RELATION_METHODS =
[
  :limit, :includes, :where, :order
].freeze

Instance Method Summary collapse

Instance Method Details

#allObject



13
14
15
# File 'lib/sql_object/searchable.rb', line 13

def all
  where({})
end

#countObject



17
18
19
# File 'lib/sql_object/searchable.rb', line 17

def count
  all.count
end

#find(id) ⇒ Object



21
22
23
# File 'lib/sql_object/searchable.rb', line 21

def find(id)
  where(id: id).first
end

#firstObject



25
26
27
# File 'lib/sql_object/searchable.rb', line 25

def first
  all.limit(1).first
end

#lastObject



29
30
31
# File 'lib/sql_object/searchable.rb', line 29

def last
  all.order(id: :desc).limit(1).first
end