Sha256: 30b568325453a2324167967e92f60dd74da77b79b7b892711ba93680e357f54c

Contents?: true

Size: 701 Bytes

Versions: 6

Compression:

Stored size: 701 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[:subquery].nil?
        query = values[:subquery].is_a?(ActiveHouse::QueryBuilder) ? values[:subquery].to_query : values[:subquery].to_s
        "( #{query} )"
      end

      def build_from_query_part
        "FROM #{from_subquery}"
      end

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

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
active_house-0.6.3 lib/active_house/querying/from.rb
active_house-0.6.2 lib/active_house/querying/from.rb
active_house-0.6.1 lib/active_house/querying/from.rb
active_house-0.6.0 lib/active_house/querying/from.rb
active_house-0.5.1 lib/active_house/querying/from.rb
active_house-0.5.0 lib/active_house/querying/from.rb