Sha256: 39b777398f948cc0929f531ca757a0e468ccd80ebe8bf4eace6bf753c81b8fc0

Contents?: true

Size: 928 Bytes

Versions: 4

Compression:

Stored size: 928 Bytes

Contents

# encoding: utf-8

module QueryBuilder::CQL

  module Modifiers

    # Provides columns for DELETE statement
    #
    module Delete

      # Adds columns that should be deleted
      #
      # @param [#to_s, Array<#to_s>] columns
      #
      # @return [QueryBuilder::Core::Statement] updated statement
      #
      def delete(*columns)
        columns.map { |name| Clause.new(name: name) }.inject(self, :<<)
      end

      private

      def maybe_columns
        clauses(:column).join(", ")
      end

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

        type :column
        attribute :name, required: true

        # @private
        def to_s
          return name.to_s unless name.instance_of? Array
          "(#{name.join(", ")})"
        end

      end # class Clause

    end # module Delete

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