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
#all ⇒ Object
13 14 15 |
# File 'lib/sql_object/searchable.rb', line 13 def all where({}) end |
#count ⇒ Object
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 |
#first ⇒ Object
25 26 27 |
# File 'lib/sql_object/searchable.rb', line 25 def first all.limit(1).first end |
#last ⇒ Object
29 30 31 |
# File 'lib/sql_object/searchable.rb', line 29 def last all.order(id: :desc).limit(1).first end |