Class: Mongoid::Relations::Proxy
- Includes:
- Threaded::Lifecycle
- Defined in:
- lib/mongoid/relations/proxy.rb
Overview
This class is the superclass for all relation proxy objects, and contains common behaviour for all of them.
Instance Attribute Summary collapse
-
#base ⇒ Object
Returns the value of attribute base.
-
#loaded ⇒ Object
Returns the value of attribute loaded.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#target ⇒ Object
Returns the value of attribute target.
Instance Method Summary collapse
-
#init(base, target, metadata) {|_self| ... } ⇒ Object
Convenience for setting the target and the metadata properties since all proxies will need to do this.
-
#substitutable ⇒ Object
The default substitutable object for a relation proxy is the clone of the target.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object (protected)
Default behavior of method missing should be to delegate all calls to the target of the proxy. This can be overridden in special cases.
103 104 105 |
# File 'lib/mongoid/relations/proxy.rb', line 103 def method_missing(name, *args, &block) target.send(name, *args, &block) end |
Instance Attribute Details
#base ⇒ Object
Returns the value of attribute base.
18 19 20 |
# File 'lib/mongoid/relations/proxy.rb', line 18 def base @base end |
#loaded ⇒ Object
Returns the value of attribute loaded.
18 19 20 |
# File 'lib/mongoid/relations/proxy.rb', line 18 def loaded @loaded end |
#metadata ⇒ Object
Returns the value of attribute metadata.
18 19 20 |
# File 'lib/mongoid/relations/proxy.rb', line 18 def @metadata end |
#target ⇒ Object
Returns the value of attribute target.
18 19 20 |
# File 'lib/mongoid/relations/proxy.rb', line 18 def target @target end |
Instance Method Details
#init(base, target, metadata) {|_self| ... } ⇒ Object
Convenience for setting the target and the metadata properties since all proxies will need to do this.
36 37 38 39 40 |
# File 'lib/mongoid/relations/proxy.rb', line 36 def init(base, target, ) @base, @target, @metadata = base, target, yield(self) if block_given? extend_proxy(.extension) if .extension? end |
#substitutable ⇒ Object
The default substitutable object for a relation proxy is the clone of the target.
51 52 53 |
# File 'lib/mongoid/relations/proxy.rb', line 51 def substitutable target end |