module Db2Query::Helper::ClassMethods
Public Instance Methods
sql_with_extention(sql, extention)
click to toggle source
# File lib/db2_query/helper.rb, line 19 def sql_with_extention(sql, extention) if sql.scan(/\@extention+/).length == 0 raise Db2Query::ExtentionError, "Missing @extention pointer at SQL" end sql.gsub("@extention", extention.strip) end
sql_with_list(sql, list)
click to toggle source
# 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
Private Instance Methods
fetch_error_message()
click to toggle source
# File lib/db2_query/helper.rb, line 44 def fetch_error_message "`fetch`, `fetch_list` and `fetch_extention` methods applied for SQL `select` statement only." end
sql_query_method?(method_name)
click to toggle source
# File lib/db2_query/helper.rb, line 35 def sql_query_method?(method_name) sql_query_name = sql_query_symbol(method_name) sql_query_methods.include?(sql_query_name) end
sql_query_methods()
click to toggle source
# File lib/db2_query/helper.rb, line 27 def sql_query_methods self.instance_methods.grep(/_sql/) end
sql_query_symbol(method_name)
click to toggle source
# File lib/db2_query/helper.rb, line 31 def sql_query_symbol(method_name) "#{method_name}_sql".to_sym end
validate_sql(sql)
click to toggle source
# File lib/db2_query/helper.rb, line 40 def validate_sql(sql) raise Db2Query::Error, "SQL have to be in string format" unless sql.is_a?(String) end