Module: Mongo::Locking
- Extended by:
- Locking
- Includes:
- Exceptions
- Included in:
- Locking
- Defined in:
- lib/mongo/locking.rb,
lib/mongo/locking/locker.rb,
lib/mongo/locking/model_methods.rb
Defined Under Namespace
Modules: Exceptions, ModelMethods Classes: Locker
Constant Summary collapse
- LOCK_INDICES =
Document Indices
A Mongoid model would look like:
field :scope, :type => String field :key, :type => String field :refcount, :type => Integer, :default => 0 field :expire_at, :type => DateTime index [ [ :scope, Mongo::ASCENDING ], [ :key, Mongo::ASCENDING ] ], :unique => true index :refcount index :expire_at
{ [["scope", Mongo::ASCENDING], ["key", Mongo::ASCENDING]] => { :unique => true, :background => true }, [["refcount", Mongo::ASCENDING]] => { :unique => false, :background => true }, [["expire_at", Mongo::ASCENDING]] => { :unique => false, :background => true }, }
Instance Attribute Summary collapse
-
#collection ⇒ Object
Allow for a proc to be initially set as the collection, in case of delayed loading/configuration/whatever.
-
#logger ⇒ Object
Returns the value of attribute logger.
Instance Method Summary collapse
Instance Attribute Details
#collection ⇒ Object
Allow for a proc to be initially set as the collection, in case of delayed loading/configuration/whatever. It’ll only be materialized when first accessed, which is presumably either when ensure_indices is called imperatively, or more likely upon the first lock call.
57 58 59 |
# File 'lib/mongo/locking.rb', line 57 def collection @collection end |
#logger ⇒ Object
Returns the value of attribute logger.
31 32 33 |
# File 'lib/mongo/locking.rb', line 31 def logger @logger end |
Instance Method Details
#configure(opts = {}) ⇒ Object
Configuration
42 43 44 45 |
# File 'lib/mongo/locking.rb', line 42 def configure(opts = {}) opts.each { |k, v| send("#{k}=", v) } return self end |
#ensure_indices ⇒ Object
84 85 86 87 88 |
# File 'lib/mongo/locking.rb', line 84 def ensure_indices LOCK_INDICES.each do |spec, opts| @collection.ensure_index(spec, opts) end end |
#included(klass) ⇒ Object
34 35 36 |
# File 'lib/mongo/locking.rb', line 34 def included(klass) klass.send(:include, ModelMethods) end |