Module: ClusterPoint::FinderMethods
- Included in:
- Document
- Defined in:
- lib/cluster_point/finder_methods.rb
Instance Method Summary collapse
Instance Method Details
#all ⇒ Object
5 6 7 |
# File 'lib/cluster_point/finder_methods.rb', line 5 def all() respToArray(JSON.parse(get_cp.where({type: self.to_s.upcase}))) end |
#find(*ids) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/cluster_point/finder_methods.rb', line 9 def find(*ids) expects_array = ids.first.kind_of?(Array) return ids.first if expects_array && ids.first.empty? ids = ids.flatten.compact.uniq case ids.size when 0 raise when 1 result = get(ids.first) expects_array ? [ result ] : result else get_some(ids) end end |
#get(id) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/cluster_point/finder_methods.rb', line 27 def get(id) result = JSON.parse(get_cp.where({id: id, type: self.to_s.upcase})) if result["found"].to_i > 0 self.from_hash(result["documents"][id], self) else raise RecordNotFound end end |