Module: Simple::SQL::Encoder

Extended by:
Encoder
Included in:
Encoder
Defined in:
lib/simple/sql/encoder.rb

Overview

private

Instance Method Summary collapse

Instance Method Details

#encode_arg(connection, arg) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/simple/sql/encoder.rb', line 9

def encode_arg(connection, arg)
  return arg unless arg.is_a?(Array)

  if arg.first.is_a?(String)
    "{#{arg.map { |a| "\"#{connection.escape(a)}\"" }.join(',')}}"
  else
    "{#{arg.join(',')}}"
  end
end

#encode_args(connection, args) ⇒ Object



5
6
7
# File 'lib/simple/sql/encoder.rb', line 5

def encode_args(connection, args)
  args.map { |arg| encode_arg(connection, arg) }
end