class Octopus::RelationProxy
Constants
- BATCH_METHODS
- ENUM_METHODS
methods redefined in
ActiveRecord
that should run_on_shard- ENUM_WITH_BLOCK_METHODS
`find { … }` etc. should run_on_shard, `find(id)` should be sent to relation
- WHERE_CHAIN_METHODS
Attributes
ar_relation[RW]
Public Class Methods
new(shard, ar_relation)
click to toggle source
# File lib/octopus/relation_proxy.rb, line 14 def initialize(shard, ar_relation) @current_shard = shard @ar_relation = ar_relation end
Public Instance Methods
==(other)
click to toggle source
# File lib/octopus/relation_proxy.rb, line 58 def ==(other) case other when ::Octopus::RelationProxy method_missing(:==, other.ar_relation) else method_missing(:==, other) end end
Also aliased as: eql?
method_missing(method, *args, &block)
click to toggle source
# File lib/octopus/relation_proxy.rb, line 32 def method_missing(method, *args, &block) if !block && BATCH_METHODS.include?(method) ::Enumerator.new do |yielder| run_on_shard do @ar_relation.public_send(method, *args) do |batch_item| yielder << batch_item end end end elsif ENUM_METHODS.include?(method) || block && ENUM_WITH_BLOCK_METHODS.include?(method) run_on_shard { @ar_relation.to_a }.public_send(method, *args, &block) elsif WHERE_CHAIN_METHODS.include?(method) ::Octopus::ScopeProxy.new(@current_shard, run_on_shard { @ar_relation.public_send(method, *args) } ) elsif block @ar_relation.public_send(method, *args, &block) else run_on_shard do if method == :load_records @ar_relation.send(method, *args) else @ar_relation.public_send(method, *args) end end end end
respond_to?(*args)
click to toggle source
# File lib/octopus/relation_proxy.rb, line 19 def respond_to?(*args) method_missing(:respond_to?, *args) end