Module: Db2Query::Helper::ClassMethods

Defined in:
lib/db2_query/helper.rb

Instance Method Summary collapse

Instance Method Details

#sql_with_extension(sql, extension) ⇒ Object Also known as: sql_with_extention



19
20
21
22
23
24
# File 'lib/db2_query/helper.rb', line 19

def sql_with_extension(sql, extension)
  if sql.scan(/\@extension+/).length == 0
    raise Db2Query::ExtensionError, "Missing @extension pointer at SQL"
  end
  sql.gsub("@extension", extension.strip)
end

#sql_with_list(sql, list) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/db2_query/helper.rb', line 10

def sql_with_list(sql, list)
  if sql.scan(/\@list+/).length == 0
    raise Db2Query::MissingListError, "Missing @list pointer at SQL"
  elsif !list.is_a?(Array)
    raise Db2Query::ListTypeError, "The arguments should be an array of list"
  end
  sql.gsub("@list", "'#{list.join("', '")}'")
end