subset_validator 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.rdoc +5 -5
  2. data/VERSION +1 -1
  3. data/subset_validator.gemspec +1 -1
  4. metadata +3 -3
data/README.rdoc CHANGED
@@ -23,7 +23,7 @@ Say you have a User model, and each user can have multiple roles, like this:
23
23
  end
24
24
  end
25
25
  You probably want your model to prevent arbitrary roles from being assigned. Eg:
26
- the_boss = User.new %w(bonehead)
26
+ the_boss = User.new %w(admin manager bonehead)
27
27
  One solution is to write a custom setter method that checks if each element of the _roles_ array is contained in <i>@@valid_roles</i> . That's a pain in the ass, especially if you need to do it more than once.
28
28
 
29
29
  Enter SubsetValidator:
@@ -46,16 +46,16 @@ Enter SubsetValidator:
46
46
  end
47
47
  end
48
48
  That one validation takes care of it all for you:
49
- the_boss = User.new %w(bonehead)
50
- => #<User:0x9980a04 @roles=["bonehead"]>
49
+ the_boss = User.new %w(admin manager bonehead)
50
+ => #<User:0x91e4aac @roles=["admin", "manager", "bonehead"]>
51
51
 
52
52
  the_boss.valid?
53
53
  => false
54
54
  the_boss.errors
55
55
  => {:roles=>["contains an invalid value"]}
56
56
 
57
- the_boss.roles = %w(manager)
58
- => ["manager"]
57
+ the_boss.roles = %w(admin manager)
58
+ => ["admin", "manager"]
59
59
  the_boss.valid?
60
60
  => true
61
61
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.4.1
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{subset_validator}
8
- s.version = "0.4.0"
8
+ s.version = "0.4.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Nick Hoffman"]
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 4
8
- - 0
9
- version: 0.4.0
8
+ - 1
9
+ version: 0.4.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Nick Hoffman
@@ -113,7 +113,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - ">="
115
115
  - !ruby/object:Gem::Version
116
- hash: 361417683
116
+ hash: -197131887
117
117
  segments:
118
118
  - 0
119
119
  version: "0"