Sha256: 93f6d37010d10f8587e9a3413488dc0309774ed50304dcf1fa8a3e0eab418e80

Contents?: true

Size: 1.17 KB

Versions: 3

Compression:

Stored size: 1.17 KB

Contents

require 'rom/sql/header'

require 'rom/sql/relation/class_methods'
require 'rom/sql/relation/reading'
require 'rom/sql/relation/writing'
require 'rom/sql/relation/inspection'
require 'rom/sql/relation/associations'

module ROM
  module SQL
    # Sequel-specific relation extensions
    #
    class Relation < ROM::Relation
      adapter :sql

      extend ClassMethods

      include Inspection
      include Associations
      include Writing
      include Reading

      # @attr_reader [Header] header Internal lazy-initialized header
      attr_reader :header

      # Name of the table used in FROM clause
      #
      # @attr_reader [Symbol] table
      attr_reader :table

      # @api private
      def initialize(dataset, registry = {})
        super
        @table = dataset.opts[:from].first
      end

      # Return a header for this relation
      #
      # @return [Header]
      #
      # @api private
      def header
        @header ||= Header.new(dataset.opts[:select] || dataset.columns, table)
      end

      # Return raw column names
      #
      # @return [Array<Symbol>]
      #
      # @api private
      def columns
        dataset.columns
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rom-sql-0.6.1 lib/rom/sql/relation.rb
rom-sql-0.6.0 lib/rom/sql/relation.rb
rom-sql-0.6.0.rc1 lib/rom/sql/relation.rb