Sha256: 011693baacdf8c2d0e0cfeb8a765d0cd9d89ee35c428fb056a2e15d6dcb2d0e2

Contents?: true

Size: 727 Bytes

Versions: 3

Compression:

Stored size: 727 Bytes

Contents

module Torque
  module PostgreSQL
    module Base
      extend ActiveSupport::Concern

      included do
        class_attribute :auxiliary_statements_list, instance_accessor: true
        self.auxiliary_statements_list = {}
      end

      module ClassMethods
        delegate :distinct_on, :with, to: :all

        protected

          # Creates a new auxiliary statement (CTE) under the base class
          def auxiliary_statement(table, &block)
            klass = AuxiliaryStatement.lookup(table, self)
            auxiliary_statements_list[table.to_sym] = klass
            klass.configurator(block)
          end
          alias cte auxiliary_statement
      end
    end

    ActiveRecord::Base.include Base
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
torque-postgresql-0.1.2 lib/torque/postgresql/base.rb
torque-postgresql-0.1.1 lib/torque/postgresql/base.rb
torque-postgresql-0.1.0 lib/torque/postgresql/base.rb