Sha256: 9bec33d480b44cc821698c70b990cb384ce603c017f8d5db4eff0dbaf1061416

Contents?: true

Size: 490 Bytes

Versions: 1

Compression:

Stored size: 490 Bytes

Contents

module Replicat
  class ScopeProxy
    def initialize(attributes)
      @klass = attributes[:klass]
      @connection_name = attributes[:connection_name]
    end

    private

    def method_missing(method_name, *args, &block)
      result = using { @klass.send(method_name, *args, &block) }
      if result.respond_to?(:scoped)
        @klass = result
        self
      else
        result
      end
    end

    def using
      @klass.using(@connection_name) { yield }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
replicat-0.0.2 lib/replicat/scope_proxy.rb