Sha256: 0172c2c1183dff02327a730a66c6fdb763e728a5f934d613337ed2e4dc9c6a66

Contents?: true

Size: 801 Bytes

Versions: 4

Compression:

Stored size: 801 Bytes

Contents

# encoding: utf-8

module QueryBuilder::CQL

  module Modifiers

    # Provides IF clauses for statements
    #
    module If

      # Adds IF clause to the statement
      #
      # @param [Hash] options
      #
      # @return [QueryBuilder::Core::Statement] updated statement
      #
      def if(options)
        options
          .map { |key, value| Clause.new(column: key, value: value) }
          .inject(self, :<<)
      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 < BaseCondition

        type :if

      end # class Clause

    end # module If

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