rolistic 1.0.0 → 1.2.0
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.
- checksums.yaml +4 -4
- data/lib/rolistic/version.rb +1 -1
- data/lib/rolistic.rb +16 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e3a79dff3028c0f5feb2831a79fb492b21e4cec78b605614e7b3e385641790d5
|
|
4
|
+
data.tar.gz: 2efd2b848043ae29225cf36d8b17387d8166ae5015c316f8f6ff5a237c9cdf61
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '08b34e31ffa71292dea73e135961a467007d1c91db626e82641101b350a058a74f06e5d78eb54439b20bf0189a6426cf969c7bc60f26011dfbe3016f6a4f126f'
|
|
7
|
+
data.tar.gz: c0714fe5580bb1dbc756f840d014790654eef4c9e95fe674f7b49ab3ba803f81302fa0d66b8276f2116d1da26e604c638376ab44c4cf59d92d5d861c7b235959
|
data/lib/rolistic/version.rb
CHANGED
data/lib/rolistic.rb
CHANGED
|
@@ -29,7 +29,22 @@ module Rolistic
|
|
|
29
29
|
name == self.class.default
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
+
# roles are value objects: abilities are derived from the class and name, so
|
|
33
|
+
# two roles of the same class and name are equal. This lets ActiveRecord see
|
|
34
|
+
# assigning an equivalent role as no change.
|
|
35
|
+
def ==(other)
|
|
36
|
+
other.class == self.class && other.name == name
|
|
37
|
+
end
|
|
38
|
+
alias_method :eql?, :==
|
|
39
|
+
|
|
40
|
+
def hash
|
|
41
|
+
[self.class, name].hash
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# name.inspect quotes names that need it and shows a missing name as nil.
|
|
45
|
+
# roles without a definition have no abilities, so they are marked as such.
|
|
32
46
|
def inspect
|
|
33
|
-
"
|
|
47
|
+
undefined = " (undefined)" unless self.class.find_role(name)
|
|
48
|
+
"#<#{self.class} #{name.inspect}#{undefined}>"
|
|
34
49
|
end
|
|
35
50
|
end
|