Module: Mongo::Model::Validation

Defined in:
lib/mongo/model/validation.rb

Instance Method Summary collapse

Instance Method Details

#create_object(*args) ⇒ Object

Catching erros during CRUD and adding it to errors, like unique index.



10
11
12
13
14
# File 'lib/mongo/model/validation.rb', line 10

def create_object *args
  with_exceptions_as_errors do
    super
  end
end

#delete_object(*args) ⇒ Object



22
23
24
25
26
# File 'lib/mongo/model/validation.rb', line 22

def delete_object *args
  with_exceptions_as_errors do
    super
  end
end

#invalid?(options = {}) ⇒ Boolean

Returns:



6
# File 'lib/mongo/model/validation.rb', line 6

def invalid?(options = {}); !valid?(options) end

#update_object(*args) ⇒ Object



16
17
18
19
20
# File 'lib/mongo/model/validation.rb', line 16

def update_object *args
  with_exceptions_as_errors do
    super
  end
end

#valid?(options = {}) ⇒ Boolean

Returns:



2
3
4
5
# File 'lib/mongo/model/validation.rb', line 2

def valid? options = {}
  errors.clear
  run_validations options
end