Sha256: e792976402e133e88e6117eba0dca522f3b1413e6a953c8bc373a4636e0f2855

Contents?: true

Size: 597 Bytes

Versions: 6

Compression:

Stored size: 597 Bytes

Contents

module Cassanity
  module ArgumentGenerators
    class WithClause

      # Internal
      def call(args = {})
        with = args[:with]
        cql = ''

        return [cql] if with.nil? || with.empty?

        variables, withs = [], []

        with.each do |key, value|
          if key == :compact_storage
            if value
              withs << "COMPACT STORAGE"
            end
          else
            withs << "#{key} = ?"
            variables << value
          end
        end

        cql << " WITH #{withs.join(' AND ')}"

        [cql, *variables]
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
cassanity-0.6.0 lib/cassanity/argument_generators/with_clause.rb
cassanity-0.6.0.beta5 lib/cassanity/argument_generators/with_clause.rb
cassanity-0.6.0.beta4 lib/cassanity/argument_generators/with_clause.rb
cassanity-0.6.0.beta3 lib/cassanity/argument_generators/with_clause.rb
cassanity-0.6.0.beta2 lib/cassanity/argument_generators/with_clause.rb
cassanity-0.6.0.beta1 lib/cassanity/argument_generators/with_clause.rb