fromage 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/fromage/version.rb +1 -1
- data/lib/mongoid/fromage.rb +24 -27
- metadata +10 -10
data/lib/fromage/version.rb
CHANGED
data/lib/mongoid/fromage.rb
CHANGED
@@ -15,41 +15,38 @@ module Mongoid
|
|
15
15
|
scope :all_role, lambda {|*role| all_in(:roles => role)}
|
16
16
|
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
18
|
+
def add_role(*roles)
|
19
|
+
self.roles += roles
|
20
|
+
end
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
def add_role!(*args)
|
23
|
+
self.add_role(*args)
|
24
|
+
self.save
|
25
|
+
end
|
27
26
|
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
def remove_role(role)
|
28
|
+
self.roles.tap {|roles| roles.delete(role)}
|
29
|
+
end
|
31
30
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
def remove_role!(role)
|
32
|
+
self.remove_role(role)
|
33
|
+
self.save
|
34
|
+
end
|
36
35
|
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
def has_role?(role)
|
37
|
+
self.roles.include? role
|
38
|
+
end
|
40
39
|
|
41
|
-
|
42
|
-
|
43
|
-
|
40
|
+
def has_roles?(*args)
|
41
|
+
args.all? {|role| self.has_role?(role) }
|
42
|
+
end
|
44
43
|
|
45
|
-
|
44
|
+
protected
|
46
45
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
46
|
+
def valid_roles?
|
47
|
+
if (self.roles - self.class.roles).any?
|
48
|
+
errors.add(:roles, :not_included)
|
51
49
|
end
|
52
|
-
|
53
50
|
end
|
54
51
|
|
55
52
|
module ClassMethods
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fromage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-02-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &20263540 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '2.7'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *20263540
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activesupport
|
27
|
-
requirement: &
|
27
|
+
requirement: &20263020 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '3.1'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *20263020
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: mongoid
|
38
|
-
requirement: &
|
38
|
+
requirement: &20262180 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '2.3'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *20262180
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: bson_ext
|
49
|
-
requirement: &
|
49
|
+
requirement: &20261320 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '1.5'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *20261320
|
58
58
|
description: Role model for mongoid.
|
59
59
|
email: jboyer@af83.com
|
60
60
|
executables: []
|