Class: Octopus::RelationProxy
- Inherits:
-
Object
- Object
- Octopus::RelationProxy
- Includes:
- ShardTracking::Attribute
- Defined in:
- lib/octopus/relation_proxy.rb
Instance Attribute Summary collapse
-
#ar_relation ⇒ Object
Returns the value of attribute ar_relation.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #as_json(options = nil) ⇒ Object
-
#initialize(shard, ar_relation) ⇒ RelationProxy
constructor
A new instance of RelationProxy.
-
#inspect ⇒ Object
these methods are not normally sent to method_missing.
- #method_missing(method, *args, &block) ⇒ Object
- #respond_to?(*args) ⇒ Boolean
Methods included from ShardTracking::Attribute
Constructor Details
#initialize(shard, ar_relation) ⇒ RelationProxy
Returns a new instance of RelationProxy.
7 8 9 10 |
# File 'lib/octopus/relation_proxy.rb', line 7 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
12 13 14 |
# File 'lib/octopus/relation_proxy.rb', line 12 def method_missing(method, *args, &block) run_on_shard { @ar_relation.send(method, *args, &block) } end |
Instance Attribute Details
#ar_relation ⇒ Object
Returns the value of attribute ar_relation.
5 6 7 |
# File 'lib/octopus/relation_proxy.rb', line 5 def ar_relation @ar_relation end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
29 30 31 32 33 34 35 36 |
# File 'lib/octopus/relation_proxy.rb', line 29 def ==(other) case other when Octopus::RelationProxy method_missing(:==, other.ar_relation) else method_missing(:==, other) end end |
#as_json(options = nil) ⇒ Object
25 26 27 |
# File 'lib/octopus/relation_proxy.rb', line 25 def as_json( = nil) method_missing(:as_json, ) end |
#inspect ⇒ Object
these methods are not normally sent to method_missing
21 22 23 |
# File 'lib/octopus/relation_proxy.rb', line 21 def inspect method_missing(:inspect) end |
#respond_to?(*args) ⇒ Boolean
16 17 18 |
# File 'lib/octopus/relation_proxy.rb', line 16 def respond_to?(*args) super || @ar_relation.respond_to?(*args) end |