Module: Uniquify
- Included in:
- ActiveRecord::Base
- Defined in:
- lib/uniquify.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
2 3 4 |
# File 'lib/uniquify.rb', line 2 def self.included(base) base.extend ClassMethods end |
Instance Method Details
#ensure_unique(name) ⇒ Object
6 7 8 9 10 |
# File 'lib/uniquify.rb', line 6 def ensure_unique(name) begin self[name] = yield end while self.class.exists?(name => self[name]) end |