Sha256: 08c0b895005570ea5cb7bd6f9164f8bc0c9c0f8c8a76bad8db7b31600a64b508

Contents?: true

Size: 681 Bytes

Versions: 5

Compression:

Stored size: 681 Bytes

Contents

module ActiveHouse
  module Querying
    module From
      extend ActiveSupport::Concern

      included do
        private :build_from_query_part, :from_subquery
      end

      def from_subquery
        return model_class._table_name if values[:from].nil?
        query = values[:from].is_a?(ActiveHouse::QueryBuilder) ? values[:from].to_query : values[:from].to_s
        "( #{query} )"
      end

      def build_from_query_part
        "FROM #{from_subquery}"
      end

      def from!(table_or_subquery)
        values[:from] = table_or_subquery.dup
        self
      end

      def from(table_or_subquery)
        dup.from!(table_or_subquery)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
active_house-0.8.0 lib/active_house/querying/from.rb
active_house-0.7.0 lib/active_house/querying/from.rb
active_house-0.6.6 lib/active_house/querying/from.rb
active_house-0.6.5 lib/active_house/querying/from.rb
active_house-0.6.4 lib/active_house/querying/from.rb