mongodb_model 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -40,7 +40,11 @@ module Mongo::Model::Assignment
40
40
  if mass_assignment or force
41
41
  v = type.cast(v) if type
42
42
  send "#{n}=", v
43
+ else
44
+ raise "mass assignment for :#{n} attribute not allowed!"
43
45
  end
46
+ else
47
+ raise "mass assignment for :#{n} attribute not allowed!"
44
48
  end
45
49
  end
46
50
  else
@@ -21,6 +21,7 @@ module Mongo::Model
21
21
 
22
22
  variables = {}; ::Mongo::Object.each_object_instance_variable(self){|n, v| variables[n] = v}
23
23
  o_variables = {}; ::Mongo::Object.each_object_instance_variable(o){|n, v| o_variables[n] = v}
24
+
24
25
  variables == o_variables
25
26
  end
26
27
 
@@ -25,8 +25,8 @@ module Mongo::Model::Validation
25
25
  add_validations(args, Mongo::Model::UniquenessValidator)
26
26
  end
27
27
 
28
- def validate validation
29
- validations << validation
28
+ def validate validation = nil, &block
29
+ validations.push block || validation
30
30
  end
31
31
 
32
32
  protected
@@ -36,7 +36,8 @@ describe 'Model callbacks' do
36
36
  end
37
37
 
38
38
  u = User.new
39
- u.set name: 'Alex', has_mail: '1', age: '31', position: [11, 34] ,banned: '0'
39
+ u.set name: 'Alex', has_mail: '1', age: '31', position: [11, 34]
40
+ -> {u.set name: 'Alex', banned: false}.should raise_error(/not allowed/)
40
41
  [u.name, u.has_mail, u.age, u.position, u.banned].should == ['Alex', true, 31, [11, 34], nil]
41
42
 
42
43
  # should allow to forcefully cast and update any attribute
@@ -67,7 +67,6 @@ describe "Attribute Convertors" do
67
67
 
68
68
  # # protection
69
69
  o.protected_tags = []
70
- o.set protected_tags_as_string: 'Java, Ruby'
71
- o.protected_tags.should == []
70
+ -> {o.set protected_tags_as_string: 'Java, Ruby'}.should raise_error(/not allowed/)
72
71
  end
73
72
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongodb_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: