Module: Kangaroo::Model::Finder
- Included in:
- Base
- Defined in:
- lib/kangaroo/model/finder.rb
Constant Summary collapse
- RELATION_DELEGATES =
%w(where limit offset order select context reverse)
Instance Method Summary collapse
-
#all ⇒ Array
Retrieve all records.
-
#count ⇒ Number
Count number of records.
- #exists?(ids) ⇒ Boolean
-
#find(id_or_keyword) ⇒ Object
ActiveRecord-ish find method.
-
#first ⇒ Object
Retrieve first record.
-
#last ⇒ Object
Retrieve last record.
Instance Method Details
#all ⇒ Array
Retrieve all records
12 13 14 |
# File 'lib/kangaroo/model/finder.rb', line 12 def all relation.all end |
#count ⇒ Number
Count number of records
58 59 60 |
# File 'lib/kangaroo/model/finder.rb', line 58 def count count_by end |
#exists?(ids) ⇒ Boolean
37 38 39 |
# File 'lib/kangaroo/model/finder.rb', line 37 def exists? ids where(:id => ids).exists? end |
#find(id) ⇒ Object #find(keyword) ⇒ Object
ActiveRecord-ish find method
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/kangaroo/model/finder.rb', line 24 def find id_or_keyword case id_or_keyword when :all, 'all' all when :first, 'first' first when :last, 'last' last else super end end |
#first ⇒ Object
Retrieve first record
44 45 46 |
# File 'lib/kangaroo/model/finder.rb', line 44 def first relation.first end |
#last ⇒ Object
Retrieve last record
51 52 53 |
# File 'lib/kangaroo/model/finder.rb', line 51 def last relation.last end |