Module: MongoMapper::Plugins::CustomScope::ClassMethods
- Defined in:
- lib/mongo_mapper_ext/mongo_mapper/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
17 18 19 |
# File 'lib/mongo_mapper_ext/mongo_mapper/plugins/custom_scope.rb', line 17 def count ={} super .merge() end |
#find_many(options = {}) ⇒ Object
13 14 15 |
# File 'lib/mongo_mapper_ext/mongo_mapper/plugins/custom_scope.rb', line 13 def find_many = {} super .merge() end |
#find_one(options = {}) ⇒ Object
9 10 11 |
# File 'lib/mongo_mapper_ext/mongo_mapper/plugins/custom_scope.rb', line 9 def find_one = {} super .merge() end |
#query(options = {}) ⇒ Object
5 6 7 |
# File 'lib/mongo_mapper_ext/mongo_mapper/plugins/custom_scope.rb', line 5 def query = {} super .merge() end |
#with_exclusive_scope(options = {}, &block) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/mongo_mapper_ext/mongo_mapper/plugins/custom_scope.rb', line 21 def with_exclusive_scope = {}, &block raise "exclusive scope already applied, can't apply it twice!" if Thread.current['mm_with_exclusive_scope'] 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
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/mongo_mapper_ext/mongo_mapper/plugins/custom_scope.rb', line 33 def with_scope = {}, &block raise "exclusive scope already applied, can't apply it twice!" if Thread.current['mm_with_exclusive_scope'] 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 |