Sha256: d4bf79dbc915417354247d0fab8512686091f3309a2c9fa8347b346a6f364284

Contents?: true

Size: 431 Bytes

Versions: 2

Compression:

Stored size: 431 Bytes

Contents

class Scrivener
  module Validations
    def assert_unique(att, model, error = [att, :not_unique])
      model  = Utils.const(self.class, model)
      record = model.with(att, send(att))

      assert(record.nil?, error)
    end

    module Utils # :nodoc:
      def self.const(context, name)
        case name
        when Symbol, String
          context.const_get(name)
        else name
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
scrivener-contrib-1.0.0 lib/scrivener/ohm.rb
scrivener-contrib-0.0.1 lib/scrivener/ohm.rb