Module: Droom::InstanceMethods
- Defined in:
- lib/droom/model_helpers.rb
Instance Method Summary collapse
Instance Method Details
#ensure_presence_and_uniqueness_of(column, base, scope = self.class.scoped) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/droom/model_helpers.rb', line 15 def ensure_presence_and_uniqueness_of(column, base, scope=self.class.scoped) unless self.send :"#{column}?" value = base addendum = 0 value = "#{base}_#{addendum+=1}" while scope.send :"find_by_#{column}", value self.send :"#{column}=", value end end |