Sha256: 5157fc8741e3eb29d6452436c48904c0e170893d624142a5d4ba0881e65259b9

Contents?: true

Size: 795 Bytes

Versions: 4

Compression:

Stored size: 795 Bytes

Contents

# encoding: utf-8

module QueryBuilder::CQL

  module Modifiers

    # Provides IF NOT EXISTS clauses for statements
    #
    module IfNotExists

      # Adds IF NOT EXISTS clause to the statement
      #
      # @return [QueryBuilder::Core::Statement] updated statement
      #
      def if_not_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
          "NOT EXISTS"
        end

      end # class Clause

    end # module IfNotExists

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