Method: Frodo::Concerns::API#count
- Defined in:
- lib/frodo/concerns/api.rb
#count(query) ⇒ Object
Public: Count the entity set or for the query passed
entity_set or query - A String or a Frodo::Query. If String is passed,
all entities for the set are counted.
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
# File 'lib/frodo/concerns/api.rb', line 235 def count(query) url_chunk = if query.is_a?(Frodo::Query) query.include_count query.to_s else service[query].query.count end body = api_get(url_chunk).body if query.is_a?(Frodo::Query) body['@odata.count'] else # Some servers (*cough* Microsoft *cough*) seem to return # extraneous characters in the response. # I found out that the _\xef\xbb\xbf contains probably invisible junk characters # called the Unicode BOM (short name for: byte order mark). body.scan(/\d+/).first.to_i end end |