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
32 33 34 |
# File 'lib/elastic_record/relation/finder_methods.rb', line 32 def all to_a end |
#find(*ids) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/elastic_record/relation/finder_methods.rb', line 4 def find(*ids) flattened_ids = ids.flatten id_filter = filter(arelastic.filter.ids(flattened_ids)) id_filter = id_filter.limit(flattened_ids.size) unless limit_value if ids.first.is_a?(Array) id_filter else case ids.size when 0; raise ActiveRecord::RecordNotFound.new('empty argument') when 1; id_filter.first! else id_filter end end end |
#find_by(*args) ⇒ Object
36 37 38 |
# File 'lib/elastic_record/relation/finder_methods.rb', line 36 def find_by(*args) filter(*args).first end |
#find_by!(*args) ⇒ Object
40 41 42 |
# File 'lib/elastic_record/relation/finder_methods.rb', line 40 def find_by!(*args) filter(*args).first! end |
#first ⇒ Object
20 21 22 |
# File 'lib/elastic_record/relation/finder_methods.rb', line 20 def first find_one self end |
#first! ⇒ Object
24 25 26 |
# File 'lib/elastic_record/relation/finder_methods.rb', line 24 def first! first or raise ActiveRecord::RecordNotFound end |
#last ⇒ Object
28 29 30 |
# File 'lib/elastic_record/relation/finder_methods.rb', line 28 def last find_one reverse_order end |