Module: FulfilApi::Relation::Countable
- Included in:
- FulfilApi::Relation
- Defined in:
- lib/fulfil_api/relation/countable.rb
Overview
The Countable extends the relation by
adding a method to count the records within a given context.
Instance Method Summary collapse
-
#count ⇒ Integer
Finds the exact number of API resources in Fulfil.
-
#counted? ⇒ true, false
Checks if the relation has already been counted.
-
#recount ⇒ Integer
Recounts the exact number of API resources in Fulfil.
Instance Method Details
#count ⇒ Integer
17 18 19 20 21 22 23 24 |
# File 'lib/fulfil_api/relation/countable.rb', line 17 def count raise FulfilApi::Resource::ModelNameMissing if model_name.nil? @count ||= FulfilApi.client.put( "/model/#{model_name}/search_count", body: { filters: conditions }.compact_blank ) end |
#counted? ⇒ true, false
Checks if the relation has already been counted.
29 30 31 |
# File 'lib/fulfil_api/relation/countable.rb', line 29 def counted? @count end |