In Files

Class/Module Index [+]

Quicksearch

Mongoid

Public Instance Methods

config() click to toggle source
Alias for: configure
configure() click to toggle source

Sets the Mongoid configuration options. Best used by passing a block.

@example Set up configuration options.

Mongoid.configure do |config|
  name = "mongoid_test"
  host = "localhost"
  config.allow_dynamic_fields = false
  config.master = Mongo::Connection.new.db(name)
end

@return [ Config ] The configuration obejct.

@since 1.0.0

# File lib/mongoid.rb, line 113
def configure
  block_given? ? yield(Config) : Config
end
Also aliased as: config
unit_of_work() click to toggle source

We can process a unit of work in Mongoid and have the identity map automatically clear itself out after the work is complete.

@example Process a unit of work.

Mongoid.unit_of_work do
  Person.create(:title => "Sir")
end

@return [ Object ] The result of the block.

@since 2.1.0

# File lib/mongoid.rb, line 129
def unit_of_work
  begin
    yield if block_given?
  ensure
    IdentityMap.clear
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.