Sha256: 189e6315448e2a5ea9ece7141566d071d6da5f8b4813e4f50652f7a63131c553

Contents?: true

Size: 556 Bytes

Versions: 3

Compression:

Stored size: 556 Bytes

Contents

module Tako
  class QueryChain
    attr_reader :proxy
    attr_reader :base_object

    def initialize(proxy, base_object)
      @proxy = proxy
      @base_object = base_object
    end

    def method_missing(method, *args)
      @proxy.in_proxy do
        if block_given?
          base_object.send(method, *args) do
            yield
          end
        else
          base_object.send(method, *args)
        end
      end
    end

    def shard(shard_name)
      new(
        Tako::Repository.shard(shard_name),
        self
      )
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tako-0.2.2 lib/tako/query_chain.rb
tako-0.2.1 lib/tako/query_chain.rb
tako-0.2.0 lib/tako/query_chain.rb