Module: Humanoid::Contexts

Defined in:
lib/humanoid/contexts/ids.rb,
lib/humanoid/contexts.rb,
lib/humanoid/contexts/mongo.rb,
lib/humanoid/contexts/paging.rb,
lib/humanoid/contexts/enumerable.rb

Overview

:nodoc:

Defined Under Namespace

Modules: Ids, Paging Classes: Enumerable, Mongo

Class Method Summary collapse

Class Method Details

.context_for(criteria) ⇒ Object

Determines the context to be used for this criteria. If the class is an embedded document, then the context will be the array in the has_many association it is in. If the class is a root, then the database itself will be the context.

Example:

Contexts.context_for(criteria)



17
18
19
20
21
22
# File 'lib/humanoid/contexts.rb', line 17

def self.context_for(criteria)
  if criteria.klass.embedded
    return Contexts::Enumerable.new(criteria)
  end
  Contexts::Mongo.new(criteria)
end