Class: Mongo::Model::Scope::ScopeProxy
- Inherits:
-
BasicObject
- Defined in:
- lib/mongo_db/model/scope.rb
Instance Method Summary
collapse
Constructor Details
#initialize(model, scope) ⇒ ScopeProxy
Returns a new instance of ScopeProxy.
3
4
5
|
# File 'lib/mongo_db/model/scope.rb', line 3
def initialize model, scope
@model, @scope = model, scope
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
23
24
25
26
27
28
29
|
# File 'lib/mongo_db/model/scope.rb', line 23
def method_missing method, *args, &block
model.with_scope scope do
result = model.send method, *args, &block
result.reverse_merge! scope if result.class == ::Mongo::Model::Scope::ScopeProxy
result
end
end
|
Instance Method Details
#inspect ⇒ Object
Also known as:
to_s
15
16
17
|
# File 'lib/mongo_db/model/scope.rb', line 15
def inspect
"#<ScopeProxy:{#{scope.inspect}}>"
end
|
#reverse_merge!(scope) ⇒ Object
11
12
13
|
# File 'lib/mongo_db/model/scope.rb', line 11
def reverse_merge! scope
@scope = scope.merge @scope
end
|