shark-permissions-core 0.1.0 → 0.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/CHANGELOG.md +4 -0
- data/lib/shark/permissions/changes.rb +9 -1
- data/lib/shark/permissions/list.rb +31 -3
- data/lib/shark/permissions/rule.rb +1 -3
- data/lib/shark/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa785346b047b8a08e057ecdd18d197e5d308b478fadb7515507f6c86e8e6cd1
|
4
|
+
data.tar.gz: a543fe0cf713c913755cfc68a51018dedb5ff8178c9243bd3151df00b111c484
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34898960845052d163f20a0816f5de43155a622c0d6c215670caa73388328eaa124f1aa480fb0313d9877c07a3bfbbab21643410d4954d7f2a0c7df2016f5e23
|
7
|
+
data.tar.gz: 3613657948b015a35f3b5da853b48ac60f40e63c7ce7e91ce5376ef7f36d8086cca26df4e72b95db5dd0ca3db21a18dbbc61dfc99ca99cdb5ba91c30aa2c889c
|
data/CHANGELOG.md
CHANGED
@@ -24,8 +24,16 @@ module Shark
|
|
24
24
|
@privileges[:new][key] = new_value
|
25
25
|
end
|
26
26
|
|
27
|
+
# @return [Boolean]
|
28
|
+
# @api public
|
29
|
+
def empty?
|
30
|
+
effect.empty? && privileges.empty?
|
31
|
+
end
|
32
|
+
|
33
|
+
# @return [Boolean]
|
34
|
+
# @api public
|
27
35
|
def present?
|
28
|
-
|
36
|
+
!empty?
|
29
37
|
end
|
30
38
|
end
|
31
39
|
end
|
@@ -107,14 +107,42 @@ module Shark
|
|
107
107
|
self.class.new(filtered_rules)
|
108
108
|
end
|
109
109
|
|
110
|
+
# @param other_list [Shark::Permissions::List]
|
111
|
+
# @return [Hash]
|
112
|
+
# @api public
|
110
113
|
def merge(other_list)
|
111
114
|
clone.merge!(other_list)
|
112
115
|
end
|
113
116
|
|
117
|
+
# Merges another list into this list. Allowed privileges are not removed.
|
118
|
+
# Changes are not tracked.
|
119
|
+
#
|
120
|
+
# @param other_list [Shark::Permissions::List]
|
121
|
+
# @return [Hash]
|
122
|
+
# @api public
|
114
123
|
def merge!(other_list)
|
115
|
-
other_list.each do |
|
116
|
-
|
117
|
-
|
124
|
+
other_list.each do |resource, rule|
|
125
|
+
if rules.key?(resource)
|
126
|
+
privileges = rules[resource].privileges
|
127
|
+
rule.privileges.each { |k, v| privileges[k] = privileges[k] || v }
|
128
|
+
else
|
129
|
+
rules[resource] = rule.clone
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
self
|
134
|
+
end
|
135
|
+
|
136
|
+
# Updates this list with rules from another list.
|
137
|
+
# All affected rules are updated and changes are tracked.
|
138
|
+
#
|
139
|
+
# @param other_list [Shark::Permissions::List]
|
140
|
+
# @return [Hash]
|
141
|
+
# @api public
|
142
|
+
def update(other_list)
|
143
|
+
other_list.each do |resource, other_rule|
|
144
|
+
rules[resource] = Permissions::Rule.new(resource: resource) unless rules.key?(resource)
|
145
|
+
rules[resource].update(other_rule)
|
118
146
|
end
|
119
147
|
|
120
148
|
self
|
@@ -62,9 +62,7 @@ module Shark
|
|
62
62
|
# @return Boolean
|
63
63
|
# @api public
|
64
64
|
def ==(other)
|
65
|
-
resource == other.resource &&
|
66
|
-
effect == other.effect &&
|
67
|
-
privileges == other.privileges
|
65
|
+
resource == other.resource && effect == other.effect && privileges == other.privileges
|
68
66
|
end
|
69
67
|
|
70
68
|
def as_json(*_args)
|
data/lib/shark/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shark-permissions-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joergen Dahlke
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-09-
|
11
|
+
date: 2021-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|