Method: DataMapper::Model::Scope#with_scope

Defined in:
lib/dm-core/model/scope.rb

#with_scope(query) ⇒ Object (protected)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Pushes given query on top of the stack

Parameters:

  • Query (Hash, Query)

    to add to current scope nesting



45
46
47
48
49
50
51
52
53
54
# File 'lib/dm-core/model/scope.rb', line 45

def with_scope(query)
  options = if query.kind_of?(Hash)
    query
  else
    query.options
  end

  # merge the current scope with the passed in query
  with_exclusive_scope(self.query.merge(options)) { |*block_args| yield(*block_args) }
end