Sha256: d4b5c79a04bc81ef096ea502cb52c99a694d59034a8df680d57e7701f774d47a

Contents?: true

Size: 1.32 KB

Versions: 1

Compression:

Stored size: 1.32 KB

Contents

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)

    # @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.2 lib/rom/relation.rb