Sha256: 0078d3c1c8caee489f47b66a25106a8b69284023915c6db26fc2f900b8fa1acc

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

module ROM
  # Repository exposes native database connection and schema when it's
  # supported by the adapter
  #
  # @api public
  class Repository
    include Concord::Public.new(:adapter)

    # Return the dataset identified by name
    #
    # @param [String,Symbol] name
    #
    # @api public
    def [](name)
      adapter[name]
    end

    # Set a logger for the adapter
    #
    # @param [Object] logger
    #
    # @api public
    def use_logger(logger)
      adapter.logger = logger
    end

    # Return logger used by the adapter
    #
    # @return [Object] logger
    #
    # @api public
    def logger
      adapter.logger
    end

    # Return the database connection provided by the adapter
    #
    # @api public
    def connection
      adapter.connection
    end

    # Return the schema provided by the adapter
    #
    # @api private
    def schema
      adapter.schema
    end

    # @api private
    def respond_to_missing?(name, include_private = false)
      adapter.dataset?(name) || super
    end

    private

    # @api private
    def method_missing(name, *args, &block)
      if adapter.dataset?(name)
        adapter[name]
      else
        super
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rom-0.5.0 lib/rom/repository.rb