Class: Octopus::RelationProxy
Defined Under Namespace
Modules: CaseFixer
Instance Attribute Summary collapse
-
#ar_relation ⇒ Object
Returns the value of attribute ar_relation.
Attributes included from ShardTracking::Attribute
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
-
#initialize(shard, ar_relation) ⇒ RelationProxy
constructor
A new instance of RelationProxy.
- #method_missing(method, *args, &block) ⇒ Object
Methods included from ShardTracking::Attribute
Constructor Details
#initialize(shard, ar_relation) ⇒ RelationProxy
Returns a new instance of RelationProxy.
14 15 16 17 |
# File 'lib/octopus/relation_proxy.rb', line 14 def initialize(shard, ar_relation) @current_shard = shard @ar_relation = ar_relation end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/octopus/relation_proxy.rb', line 19 def method_missing(method, *args, &block) if block @ar_relation.public_send(method, *args, &block) else run_on_shard { @ar_relation.public_send(method, *args) } end end |
Instance Attribute Details
#ar_relation ⇒ Object
Returns the value of attribute ar_relation.
12 13 14 |
# File 'lib/octopus/relation_proxy.rb', line 12 def ar_relation @ar_relation end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
27 28 29 30 31 32 33 34 |
# File 'lib/octopus/relation_proxy.rb', line 27 def ==(other) case other when ::Octopus::RelationProxy method_missing(:==, other.ar_relation) else method_missing(:==, other) end end |