lib/unique_identifier.rb in unique_identifier-0.0.3 vs lib/unique_identifier.rb in unique_identifier-0.0.4
- old
+ new
@@ -6,13 +6,12 @@
module ClassMethods
mattr_accessor :field, :block, :klass
def unique_id(field, block)
- @klass = self.name.constantize
- @klass.const_set('BLOCK', block)
- @klass.const_set('FIELD', field)
- @klass.set_callback(:create, :before, :generate_unique_id)
+ const_set('BLOCK', block)
+ const_set('FIELD', field)
+ before_validation :generate_unique_id, on: :create
end
end
module InstanceMethods