Sha256: b58ccd3e2b31a2ab21c854cb792e1cf93e6fd81fd2f69c90695ac990dca22818

Contents?: true

Size: 589 Bytes

Versions: 4

Compression:

Stored size: 589 Bytes

Contents

module Rein
  # The {Util} module provides utility methods for handling options.
  module Util
    def self.conditions_with_if(conditions, options = {})
      if options[:if].present?
        "NOT (#{options[:if]}) OR (#{conditions})"
      else
        conditions
      end
    end

    def self.constraint_name(table, attribute, suffix, options = {})
      options[:name].presence || "#{table}_#{attribute}_#{suffix}"
    end

    def self.wrap_identifier(attribute)
      if /^".*"$/.match?(attribute)
        attribute
      else
        "\"#{attribute}\""
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rein-5.0.0 lib/rein/util.rb
rein-4.0.0 lib/rein/util.rb
rein-3.5.0 lib/rein/util.rb
rein-3.4.0 lib/rein/util.rb