Module: MongoMapper::Plugins::DefaultScope::ClassMethods
- Defined in:
- lib/mongo_mapper_ext/plugins/default_scope.rb
Instance Method Summary collapse
- #count(options = {}) ⇒ Object
- #find_many(options = {}) ⇒ Object
- #find_one(options = {}) ⇒ Object
- #with_exclusive_scope(options = {}, &block) ⇒ Object
- #with_scope(options = {}, &block) ⇒ Object
Instance Method Details
#count(options = {}) ⇒ Object
14 15 16 |
# File 'lib/mongo_mapper_ext/plugins/default_scope.rb', line 14 def count ={} super .merge() end |
#find_many(options = {}) ⇒ Object
10 11 12 |
# File 'lib/mongo_mapper_ext/plugins/default_scope.rb', line 10 def find_many = {} super .merge() end |
#find_one(options = {}) ⇒ Object
6 7 8 |
# File 'lib/mongo_mapper_ext/plugins/default_scope.rb', line 6 def find_one = {} super .merge() end |
#with_exclusive_scope(options = {}, &block) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/mongo_mapper_ext/plugins/default_scope.rb', line 18 def with_exclusive_scope = {}, &block Thread.current['mm_with_exclusive_scope'].should! :be_nil before = Thread.current['mm_with_exclusive_scope'] begin Thread.current['mm_with_exclusive_scope'] = block.call if block ensure Thread.current['mm_with_exclusive_scope'] = before end end |
#with_scope(options = {}, &block) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/mongo_mapper_ext/plugins/default_scope.rb', line 30 def with_scope = {}, &block Thread.current['mm_with_exclusive_scope'].should! :be_nil before = Thread.current['mm_with_scope'] begin = before.merge if before Thread.current['mm_with_scope'] = block.call if block ensure Thread.current['mm_with_scope'] = before end end |