Sha256: 8db289f6520e61a0e282491f766672ef6528eff4239c56bca4f7d9dc6ae8c205

Contents?: true

Size: 1.35 KB

Versions: 1

Compression:

Stored size: 1.35 KB

Contents

require 'rom/ra'

module ROM

  # Base relation class
  #
  # Relation is a proxy for the dataset object provided by the adapter, it
  # forwards every method to the dataset that's why "native" interface of the
  # underlying adapter is available in the relation. This interface, however, is
  # considered to private and should not be used outside of the relation instance.
  #
  # ROM builds sub-classes of this class for every relation defined in the env
  # for easy inspection and extensibility - every adapter can provide extensions
  # for those sub-classes but there is always a vanilla relation instance stored
  # in the schema registry.
  #
  # Relation instances also have access to the experimental ROM::RA interface
  # giving in-memory relational operations that are very handy, especially when
  # dealing with joined relations or data coming from different sources.
  #
  # @api public
  class Relation
    include Charlatan.new(:dataset)
    include Equalizer.new(:header, :dataset)
    include RA

    # @api private
    attr_reader :header

    # @api private
    def self.finalize(env, relation)
      # noop
    end

    # @api private
    def initialize(dataset, header = dataset.header)
      super
      @header = header.dup.freeze
    end

    # @api private
    def each(&block)
      return to_enum unless block
      dataset.each(&block)
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rom-0.4.1 lib/rom/relation.rb