Class: BigRecord::BrAssociations::AssociationProxy
- Inherits:
-
Object
- Object
- BigRecord::BrAssociations::AssociationProxy
- Defined in:
- lib/big_record/br_associations/association_proxy.rb
Overview
:nodoc:
Direct Known Subclasses
AssociationCollection, BelongsToAssociation, BelongsToManyAssociation
Instance Attribute Summary
-
- (Object) reflection
readonly
Returns the value of attribute reflection.
Instance Method Summary
-
- (Object) ===(other)
Explicitly proxy === because the instance method removal above doesn’t catch it.
- - (Object) aliased_table_name
-
- (AssociationProxy) initialize(owner, reflection)
constructor
A new instance of AssociationProxy.
- - (Object) loaded
- - (Boolean) loaded?
- - (Object) proxy_owner
- - (Object) proxy_reflection
- - (Object) proxy_target
- - (Object) reload
- - (Object) reset
- - (Boolean) respond_to?(symbol, include_priv = false) (also: #proxy_respond_to?)
- - (Object) target
- - (Object) target(target)
Constructor Details
- (AssociationProxy) initialize(owner, reflection)
A new instance of AssociationProxy
10 11 12 13 14 |
# File 'lib/big_record/br_associations/association_proxy.rb', line 10 def initialize(owner, reflection) @owner, @reflection = owner, reflection Array(reflection.[:extend]).each { |ext| proxy_extend(ext) } reset end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
- (Object) method_missing(method, *args, &block) (private)
116 117 118 119 120 |
# File 'lib/big_record/br_associations/association_proxy.rb', line 116 def method_missing(method, *args, &block) if load_target @target.send(method, *args, &block) end end |
Instance Attribute Details
- (Object) reflection (readonly)
Returns the value of attribute reflection
4 5 6 |
# File 'lib/big_record/br_associations/association_proxy.rb', line 4 def reflection @reflection end |
Instance Method Details
- (Object) ===(other)
Explicitly proxy === because the instance method removal above doesn’t catch it.
34 35 36 37 |
# File 'lib/big_record/br_associations/association_proxy.rb', line 34 def ===(other) load_target other === @target end |
- (Object) aliased_table_name
39 40 41 |
# File 'lib/big_record/br_associations/association_proxy.rb', line 39 def aliased_table_name @reflection.klass.table_name end |
- (Object) loaded
57 58 59 |
# File 'lib/big_record/br_associations/association_proxy.rb', line 57 def loaded @loaded = true end |
- (Boolean) loaded?
53 54 55 |
# File 'lib/big_record/br_associations/association_proxy.rb', line 53 def loaded? @loaded end |
- (Object) proxy_owner
16 17 18 |
# File 'lib/big_record/br_associations/association_proxy.rb', line 16 def proxy_owner @owner end |
- (Object) proxy_reflection
20 21 22 |
# File 'lib/big_record/br_associations/association_proxy.rb', line 20 def proxy_reflection @reflection end |
- (Object) proxy_target
24 25 26 |
# File 'lib/big_record/br_associations/association_proxy.rb', line 24 def proxy_target @target end |
- (Object) reload
48 49 50 51 |
# File 'lib/big_record/br_associations/association_proxy.rb', line 48 def reload reset load_target end |
- (Object) reset
43 44 45 46 |
# File 'lib/big_record/br_associations/association_proxy.rb', line 43 def reset @loaded = false @target = nil end |
- (Boolean) respond_to?(symbol, include_priv = false) Also known as: proxy_respond_to?
28 29 30 |
# File 'lib/big_record/br_associations/association_proxy.rb', line 28 def respond_to?(symbol, include_priv = false) proxy_respond_to?(symbol, include_priv) || (load_target && @target.respond_to?(symbol, include_priv)) end |
- (Object) target
61 62 63 |
# File 'lib/big_record/br_associations/association_proxy.rb', line 61 def target @target end |
- (Object) target=(target)
65 66 67 68 |
# File 'lib/big_record/br_associations/association_proxy.rb', line 65 def target=(target) @target = target loaded end |