Module: Hcp::Queryable
Overview
Extends a resource with the entry points that read a list of it, or one record.
Instance Method Summary collapse
-
#all(company_id: nil) ⇒ Relation
Every record of this kind the location holds.
-
#count(company_id: nil) ⇒ Integer
How many records of this kind the location holds.
-
#expands ⇒ Array<Symbol>
What these bring back beside themselves where asked to.
-
#filters ⇒ Hash
What a list of these may be narrowed by.
-
#find(id, company_id: nil) ⇒ Resource
The record Housecall Pro files under this ID.
-
#first(company_id: nil) ⇒ Resource?
The first record, or nil where the location holds none.
-
#includes(*names, company_id: nil) ⇒ Relation
The records, with these brought back beside each of them.
-
#limit(count, company_id: nil) ⇒ Relation
At most this many records.
-
#many ⇒ Array<Symbol>
The conditions Housecall Pro takes more than one of.
-
#order(company_id: nil, **sorts) ⇒ Relation
The records in this order.
-
#sorts ⇒ Array<Symbol>
What Housecall Pro will put a list of these in order of.
-
#where(company_id: nil, **conditions) ⇒ Relation
The records matching these conditions.
Instance Method Details
#all(company_id: nil) ⇒ Relation
Returns every record of this kind the location holds.
6 |
# File 'lib/hcp/concerns/queryable.rb', line 6 def all(company_id: nil) = Relation.new type: self, company_id: company_id |
#count(company_id: nil) ⇒ Integer
Returns how many records of this kind the location holds.
21 |
# File 'lib/hcp/concerns/queryable.rb', line 21 def count(company_id: nil) = all(company_id: company_id).count |
#expands ⇒ Array<Symbol>
Returns what these bring back beside themselves where asked to.
39 |
# File 'lib/hcp/concerns/queryable.rb', line 39 def = self::EXPANDS |
#filters ⇒ Hash
Returns what a list of these may be narrowed by.
30 |
# File 'lib/hcp/concerns/queryable.rb', line 30 def filters = self::FILTERS |
#find(id, company_id: nil) ⇒ Resource
Returns the record Housecall Pro files under this ID.
27 |
# File 'lib/hcp/concerns/queryable.rb', line 27 def find(id, company_id: nil) = all(company_id: company_id).find(id) |
#first(company_id: nil) ⇒ Resource?
Returns the first record, or nil where the location holds none.
24 |
# File 'lib/hcp/concerns/queryable.rb', line 24 def first(company_id: nil) = all(company_id: company_id).first |
#includes(*names, company_id: nil) ⇒ Relation
Returns the records, with these brought back beside each of them.
18 |
# File 'lib/hcp/concerns/queryable.rb', line 18 def includes(*names, company_id: nil) = all(company_id: company_id).includes(*names) |
#limit(count, company_id: nil) ⇒ Relation
Returns at most this many records.
15 |
# File 'lib/hcp/concerns/queryable.rb', line 15 def limit(count, company_id: nil) = all(company_id: company_id).limit(count) |
#many ⇒ Array<Symbol>
Returns the conditions Housecall Pro takes more than one of.
33 |
# File 'lib/hcp/concerns/queryable.rb', line 33 def many = self::MANY |
#order(company_id: nil, **sorts) ⇒ Relation
Returns the records in this order.
12 |
# File 'lib/hcp/concerns/queryable.rb', line 12 def order(company_id: nil, **sorts) = all(company_id: company_id).order(**sorts) |
#sorts ⇒ Array<Symbol>
Returns what Housecall Pro will put a list of these in order of.
36 |
# File 'lib/hcp/concerns/queryable.rb', line 36 def sorts = self::SORTS |
#where(company_id: nil, **conditions) ⇒ Relation
Returns the records matching these conditions.
9 |
# File 'lib/hcp/concerns/queryable.rb', line 9 def where(company_id: nil, **conditions) = all(company_id: company_id).where(**conditions) |