module Rein::Util
The {Util} module provides utility methods for handling options.
Public Class Methods
add_not_valid_suffix_if_required(sql, options)
click to toggle source
Returns a new string with the suffix appended if required
# File lib/rein/util.rb, line 5 def self.add_not_valid_suffix_if_required(sql, options) suffix = options[:validate] == false ? ' NOT VALID' : '' "#{sql}#{suffix}" end
conditions_with_if(conditions, options = {})
click to toggle source
# File lib/rein/util.rb, line 10 def self.conditions_with_if(conditions, options = {}) if options[:if].present? "NOT (#{options[:if]}) OR (#{conditions})" else conditions end end
constraint_name(table, attribute, suffix, options = {})
click to toggle source
# File lib/rein/util.rb, line 18 def self.constraint_name(table, attribute, suffix, options = {}) options[:name].presence || "#{table}_#{attribute}_#{suffix}" end
wrap_identifier(attribute)
click to toggle source
# File lib/rein/util.rb, line 22 def self.wrap_identifier(attribute) if /^".*"$/.match?(attribute) attribute else "\"#{attribute}\"" end end