Module: MongoMapper::Plugins::Validations

Defined in:
lib/mongo_mapper/plugins/validations.rb

Defined Under Namespace

Modules: DocumentMacros Classes: ValidatesUniquenessOf

Class Method Summary collapse

Class Method Details

.configure(model) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/mongo_mapper/plugins/validations.rb', line 4

def self.configure(model)
  model.class_eval { include Validatable }

  if defined?(ActiveModel)
    # this methods are not defined when using rails 3
    class << model
      [:validate, :validate_on_update, :validate_on_create].each do |method|
        define_method(method) do |*args, &block|
          set_callback(method, *args, &block)
        end
      end
    end
  end
end