Sha256: 1f280faf69e73dedd525340942e0a3b53de4a0fd55ebbd80881ac9d24255551c

Contents?: true

Size: 814 Bytes

Versions: 4

Compression:

Stored size: 814 Bytes

Contents

# encoding: utf-8

module QueryBuilder::CQL

  module Modifiers

    # Provides WITH clauses for statements
    #
    module With

      # Adds WITH clause to the statement
      #
      # @param [Hash] options
      #
      # @return [QueryBuilder::Core::Statement] updated statement
      #
      def with(options)
        options
          .map { |key, value| Clause.new(column: key, value: value) }
          .inject(self, :<<)
      end

      private

      def maybe_with
        list = clauses(:with)
        ["WITH", list.join(" AND ")] if list.any?
      end

      # The clause for adding to a statement
      #
      # @api private
      #
      class Clause < BaseCondition

        type :with

      end # class Clause

    end # module With

  end # module Modifiers

end # module QueryBuilder::CQL

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
query_builder-0.0.4 lib/query_builder/cql/modifiers/with.rb
query_builder-0.0.3 lib/query_builder/cql/modifiers/with.rb
query_builder-0.0.2 lib/query_builder/cql/modifiers/with.rb
query_builder-0.0.1 lib/query_builder/cql/modifiers/with.rb