module ElasticRecord::Relation::FinderMethods
Public Instance Methods
all()
click to toggle source
# File lib/elastic_record/relation/finder_methods.rb, line 32 def all to_a end
find(*ids)
click to toggle source
# 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)
click to toggle source
# File lib/elastic_record/relation/finder_methods.rb, line 36 def find_by(*args) filter(*args).first end
find_by!(*args)
click to toggle source
# File lib/elastic_record/relation/finder_methods.rb, line 40 def find_by!(*args) filter(*args).first! end
first()
click to toggle source
# File lib/elastic_record/relation/finder_methods.rb, line 20 def first find_one self end
first!()
click to toggle source
# File lib/elastic_record/relation/finder_methods.rb, line 24 def first! first or raise ActiveRecord::RecordNotFound end
last()
click to toggle source
# File lib/elastic_record/relation/finder_methods.rb, line 28 def last find_one reverse_order end
Private Instance Methods
find_one(relation)
click to toggle source
# File lib/elastic_record/relation/finder_methods.rb, line 46 def find_one(relation) relation.limit(1).to_a.first end