Sha256: 3ff57ec869fb7b228e829cb959a09ba2df790b54b28ca81900a00099519a8adf

Contents?: true

Size: 773 Bytes

Versions: 4

Compression:

Stored size: 773 Bytes

Contents

# encoding: utf-8

module QueryBuilder::CQL

  module Modifiers

    # Provides IF EXISTS clauses for statements
    #
    module IfExists

      # Adds IF EXISTS clause to the statement
      #
      # @return [QueryBuilder::Core::Statement] updated statement
      #
      def if_exists
        self << Clause.new
      end

      private

      def maybe_if
        list = clauses(:if)
        ["IF", list.sort.join(" AND ")] if list.any?
      end

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

        unique
        type :if

        # @private
        def to_s
          "EXISTS"
        end

      end # class Clause

    end # module IfExists

  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/if_exists.rb
query_builder-0.0.3 lib/query_builder/cql/modifiers/if_exists.rb
query_builder-0.0.2 lib/query_builder/cql/modifiers/if_exists.rb
query_builder-0.0.1 lib/query_builder/cql/modifiers/if_exists.rb