Sha256: 6263b67eb5a504f67dc54b6fc60dad46fa287343024061c7f9663cd651d7cd1d

Contents?: true

Size: 490 Bytes

Versions: 4

Compression:

Stored size: 490 Bytes

Contents

module Rein
  module Constraint
    # 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
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rein-3.3.0 lib/rein/util.rb
rein-3.2.0 lib/rein/util.rb
rein-3.1.0 lib/rein/util.rb
rein-3.0.0 lib/rein/util.rb