Sha256: 358eb0b5485f8c28c2947d96e40173c578d67651f158bf1af17164c433c7d548

Contents?: true

Size: 823 Bytes

Versions: 4

Compression:

Stored size: 823 Bytes

Contents

# encoding: utf-8

module QueryBuilder::CQL

  module Modifiers

    # Provides WHERE clauses for statements
    #
    module Where

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

      private

      def maybe_where
        list = clauses(:where)
        ["WHERE", list.join(" AND ")] if list.any?
      end

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

        type :where

      end # class Clause

    end # module Where

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