Class: Cassanity::ArgumentGenerators::WithClause
- Inherits:
-
Object
- Object
- Cassanity::ArgumentGenerators::WithClause
- Defined in:
- lib/cassanity/argument_generators/with_clause.rb
Instance Method Summary collapse
-
#call(args = {}) ⇒ Object
Internal.
Instance Method Details
#call(args = {}) ⇒ Object
Internal
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/cassanity/argument_generators/with_clause.rb', line 6 def call(args = {}) with = args[:with] cql = '' return [cql] if with.nil? || with.empty? variables, withs = [], [] with.each do |key, value| if value.is_a?(Hash) value.each do |sub_key, sub_value| withs << "#{key}:#{sub_key} = ?" variables << sub_value end else withs << "#{key} = ?" variables << value end end cql << " WITH #{withs.join(' AND ')}" [cql, *variables] end |