Sha256: ec1aec3e9a76ee311a5e3e28f9a531971c328fff31ad91cf9b0bcdbeb271f723

Contents?: true

Size: 398 Bytes

Versions: 20

Compression:

Stored size: 398 Bytes

Contents

# private
module Simple::SQL::Encoder
  extend self
  extend Forwardable

  delegate connection: ::Simple::SQL

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

  def encode_arg(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
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
simple-sql-0.3.7 lib/simple/sql/encoder.rb
simple-sql-0.3.6 lib/simple/sql/encoder.rb
simple-sql-0.3.5 lib/simple/sql/encoder.rb
simple-sql-0.3.4 lib/simple/sql/encoder.rb
simple-sql-0.3.3 lib/simple/sql/encoder.rb
simple-sql-0.2.10 lib/simple/sql/encoder.rb
simple-sql-0.3.2 lib/simple/sql/encoder.rb
simple-sql-0.2.9 lib/simple/sql/encoder.rb
simple-sql-0.3.1 lib/simple/sql/encoder.rb
simple-sql-0.2.8 lib/simple/sql/encoder.rb
simple-sql-0.3.0 lib/simple/sql/encoder.rb
simple-sql-0.2.7 lib/simple/sql/encoder.rb
simple-sql-0.2.6 lib/simple/sql/encoder.rb
simple-sql-0.2.5 lib/simple/sql/encoder.rb
simple-sql-0.2.4 lib/simple/sql/encoder.rb
simple-sql-0.2.3 lib/simple/sql/encoder.rb
simple-sql-0.2.2 lib/simple/sql/encoder.rb
simple-sql-0.2.1 lib/simple/sql/encoder.rb
simple-sql-0.2.0 lib/simple/sql/encoder.rb
simple-sql-0.1.3 lib/simple/sql/encoder.rb