Module: MongoMapper::Plugins::CustomScope::ClassMethods
- Defined in:
- lib/mongo_mapper_ext/plugins/custom_scope.rb
Instance Method Summary collapse
- #count(options = {}) ⇒ Object
- #find_many(options = {}) ⇒ Object
- #find_one(options = {}) ⇒ Object
- #query(options = {}) ⇒ Object
- #with_exclusive_scope(options = {}, &block) ⇒ Object
- #with_scope(options = {}, &block) ⇒ Object
Instance Method Details
#count(options = {}) ⇒ Object
19 20 21 |
# File 'lib/mongo_mapper_ext/plugins/custom_scope.rb', line 19 def count ={} super .merge() end |
#find_many(options = {}) ⇒ Object
15 16 17 |
# File 'lib/mongo_mapper_ext/plugins/custom_scope.rb', line 15 def find_many = {} super .merge() end |
#find_one(options = {}) ⇒ Object
11 12 13 |
# File 'lib/mongo_mapper_ext/plugins/custom_scope.rb', line 11 def find_one = {} super .merge() end |
#query(options = {}) ⇒ Object
7 8 9 |
# File 'lib/mongo_mapper_ext/plugins/custom_scope.rb', line 7 def query = {} super .merge() end |
#with_exclusive_scope(options = {}, &block) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/mongo_mapper_ext/plugins/custom_scope.rb', line 23 def with_exclusive_scope = {}, &block Thread.current['mm_with_exclusive_scope'].must_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
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/mongo_mapper_ext/plugins/custom_scope.rb', line 35 def with_scope = {}, &block Thread.current['mm_with_exclusive_scope'].must_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 |