Module: ElasticRecord::Relation::FinderMethods
- Included in:
- ElasticRecord::Relation
- Defined in:
- lib/elastic_record/relation/finder_methods.rb
Instance Method Summary collapse
- #all ⇒ Object
- #find(*ids) ⇒ Object
- #find_by(*args) ⇒ Object
- #find_by!(*args) ⇒ Object
- #first ⇒ Object
- #first! ⇒ Object
- #last ⇒ Object
Instance Method Details
#all ⇒ Object
26 27 28 |
# File 'lib/elastic_record/relation/finder_methods.rb', line 26 def all to_a end |
#find(*ids) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'lib/elastic_record/relation/finder_methods.rb', line 4 def find(*ids) ids = ids.flatten case ids.size when 0; raise ActiveRecord::RecordNotFound.new('empty argument') when 1; filter(arelastic.filter.ids(ids)).first! else filter(arelastic.filter.ids(ids)) end end |
#find_by(*args) ⇒ Object
30 31 32 |
# File 'lib/elastic_record/relation/finder_methods.rb', line 30 def find_by(*args) filter(*args).first end |
#find_by!(*args) ⇒ Object
34 35 36 |
# File 'lib/elastic_record/relation/finder_methods.rb', line 34 def find_by!(*args) filter(*args).first! end |
#first ⇒ Object
14 15 16 |
# File 'lib/elastic_record/relation/finder_methods.rb', line 14 def first find_one self end |
#first! ⇒ Object
18 19 20 |
# File 'lib/elastic_record/relation/finder_methods.rb', line 18 def first! first or raise ActiveRecord::RecordNotFound end |
#last ⇒ Object
22 23 24 |
# File 'lib/elastic_record/relation/finder_methods.rb', line 22 def last find_one reverse_order end |