Class: BigRecord::EmbeddedAssociations::AssociationProxy
- Inherits:
-
Object
- Object
- BigRecord::EmbeddedAssociations::AssociationProxy
- Defined in:
- lib/big_record/embedded_associations/association_proxy.rb
Overview
:nodoc:
Instance Method Summary
-
- (Object) ===(other)
Explicitly proxy === because the instance method removal above doesn’t catch it.
- - (Object) aliased_table_name
-
- (Object) delete(*records)
Remove records from this association.
- - (Object) find(id)
- - (Object) loaded
- - (Boolean) loaded?
- - (Object) proxy_owner
- - (Object) proxy_reflection
- - (Object) proxy_target
- - (Object) reload
- - (Object) reset
- - (Boolean) respond_to?(symbol, include_priv = false)
- - (Object) target
- - (Object) target(target)
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
- (Object) method_missing(method, *args, &block) (private)
105 106 107 108 109 |
# File 'lib/big_record/embedded_associations/association_proxy.rb', line 105 def method_missing(method, *args, &block) if load_target @target.send(method, *args, &block) end end |
Instance Method Details
- (Object) ===(other)
Explicitly proxy === because the instance method removal above doesn’t catch it.
35 36 37 38 |
# File 'lib/big_record/embedded_associations/association_proxy.rb', line 35 def ===(other) load_target other === @target end |
- (Object) aliased_table_name
40 41 42 |
# File 'lib/big_record/embedded_associations/association_proxy.rb', line 40 def aliased_table_name @reflection.klass.table_name end |
- (Object) delete(*records)
Remove records from this association. Does not destroy records.
11 12 13 14 15 |
# File 'lib/big_record/embedded_associations/association_proxy.rb', line 11 def delete(*records) records = flatten_deeper(records) #records.each { |record| raise_on_type_mismatch(record) } records.reject! { |record| @target.delete(record)} end |
- (Object) find(id)
6 7 8 |
# File 'lib/big_record/embedded_associations/association_proxy.rb', line 6 def find(id) @target.select{|s| s.id == id}.first end |
- (Object) loaded
58 59 60 |
# File 'lib/big_record/embedded_associations/association_proxy.rb', line 58 def loaded @loaded = true end |
- (Boolean) loaded?
54 55 56 |
# File 'lib/big_record/embedded_associations/association_proxy.rb', line 54 def loaded? @loaded end |
- (Object) proxy_owner
17 18 19 |
# File 'lib/big_record/embedded_associations/association_proxy.rb', line 17 def proxy_owner @owner end |
- (Object) proxy_reflection
21 22 23 |
# File 'lib/big_record/embedded_associations/association_proxy.rb', line 21 def proxy_reflection @reflection end |
- (Object) proxy_target
25 26 27 |
# File 'lib/big_record/embedded_associations/association_proxy.rb', line 25 def proxy_target @target end |
- (Object) reload
49 50 51 52 |
# File 'lib/big_record/embedded_associations/association_proxy.rb', line 49 def reload reset load_target end |
- (Object) reset
44 45 46 47 |
# File 'lib/big_record/embedded_associations/association_proxy.rb', line 44 def reset @loaded = false @target = nil end |
- (Boolean) respond_to?(symbol, include_priv = false)
29 30 31 |
# File 'lib/big_record/embedded_associations/association_proxy.rb', line 29 def respond_to?(symbol, include_priv = false) proxy_respond_to?(symbol, include_priv) || (load_target && @target.respond_to?(symbol, include_priv)) end |
- (Object) target
62 63 64 |
# File 'lib/big_record/embedded_associations/association_proxy.rb', line 62 def target @target end |
- (Object) target=(target)
66 67 68 69 |
# File 'lib/big_record/embedded_associations/association_proxy.rb', line 66 def target=(target) @target = target loaded end |