Class: BigRecord::ArAssociations::AssociationProxy
- Inherits:
-
Object
- Object
- BigRecord::ArAssociations::AssociationProxy
- Defined in:
- lib/big_record/ar_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
- - (Object) conditions (also: #sql_conditions)
-
- (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/ar_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)
121 122 123 124 125 |
# File 'lib/big_record/ar_associations/association_proxy.rb', line 121 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/ar_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/ar_associations/association_proxy.rb', line 34 def ===(other) load_target other === @target end |
- (Object) aliased_table_name
39 40 41 |
# File 'lib/big_record/ar_associations/association_proxy.rb', line 39 def aliased_table_name @reflection.klass.table_name end |
- (Object) conditions Also known as: sql_conditions
43 44 45 |
# File 'lib/big_record/ar_associations/association_proxy.rb', line 43 def conditions @conditions ||= interpolate_sql(sanitize_sql(@reflection.[:conditions])) if @reflection.[:conditions] end |
- (Object) loaded
62 63 64 |
# File 'lib/big_record/ar_associations/association_proxy.rb', line 62 def loaded @loaded = true end |
- (Boolean) loaded?
58 59 60 |
# File 'lib/big_record/ar_associations/association_proxy.rb', line 58 def loaded? @loaded end |
- (Object) proxy_owner
16 17 18 |
# File 'lib/big_record/ar_associations/association_proxy.rb', line 16 def proxy_owner @owner end |
- (Object) proxy_reflection
20 21 22 |
# File 'lib/big_record/ar_associations/association_proxy.rb', line 20 def proxy_reflection @reflection end |
- (Object) proxy_target
24 25 26 |
# File 'lib/big_record/ar_associations/association_proxy.rb', line 24 def proxy_target @target end |
- (Object) reload
53 54 55 56 |
# File 'lib/big_record/ar_associations/association_proxy.rb', line 53 def reload reset load_target end |
- (Object) reset
48 49 50 51 |
# File 'lib/big_record/ar_associations/association_proxy.rb', line 48 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/ar_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
66 67 68 |
# File 'lib/big_record/ar_associations/association_proxy.rb', line 66 def target @target end |
- (Object) target=(target)
70 71 72 73 |
# File 'lib/big_record/ar_associations/association_proxy.rb', line 70 def target=(target) @target = target loaded end |