Method: ContextIO::API::ResourceCollection#where

Defined in:
lib/contextio/api/resource_collection.rb

#where(constraints) ⇒ Object

Specify one or more constraints for limiting resources in this collection. See individual classes in the Context.IO docs for the list of valid constraints. Not all collections have valid where constraints at all.

This can be chained at need and doesn't actually cause the API to get hit until some iterator is called like #each.

Examples:

accounts = contextio.accounts
accounts = accounts.where(email: '[email protected]')
accounts = accounts.where(status: 'OK')

accounts.each do ||
  # API gets hit for this call
end

Parameters:

  • constraints (Hash{String, Symbol => String, Integer})

    A Hash mapping keys to the desired limiting values.



91
92
93
# File 'lib/contextio/api/resource_collection.rb', line 91

def where(constraints)
  self.class.new(api, associations_hash.merge(where: where_constraints.merge(constraints)))
end