simple-navigation-acl 0.1.3 → 0.1.4
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/simple_navigation_acl/base.rb +11 -10
- data/lib/simple_navigation_acl/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc76fec314ad4e65a068e25567468ad9b33492c7
|
4
|
+
data.tar.gz: 9eb44ab803b6bd46c7526590d7099f94e2b48a12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db3f4d7001860ff867b590ea9343adbe1984034cbab9fbe03d7b4b3bae89424a97bdc440be24ad7d32a1fccb5028ad7f197d47e8a1dfb5ead8b5abfdb13254c4
|
7
|
+
data.tar.gz: 82e5032ca4a93d7a9ccd9c5e72e8fb52444d4b5e557882f794999cd7d5707d0d733c1fae25008bdcd0da35a43d8c6b3791b98546af64b22e4a32feb6a11cd111
|
@@ -35,21 +35,22 @@ module SimpleNavigationAcl
|
|
35
35
|
|
36
36
|
def apply_acl(navigation, id, context)
|
37
37
|
context=:default if context.nil?
|
38
|
-
rules_keys = SimpleNavigationAcl::AclRule.where(context: context)
|
39
|
-
rules_keys = rules_keys.where(id: id) unless id==:all
|
38
|
+
rules_keys = id==:all ? :all : SimpleNavigationAcl::AclRule.where(context: context).where(id: id).pluck(:key)
|
40
39
|
container = navigation.is_a?(SimpleNavigation::Configuration) ? navigation.instance_variable_get(:@primary_navigation) : navigation
|
41
|
-
filter_simple_navigation_with_rules!(container, rules_keys
|
40
|
+
filter_simple_navigation_with_rules!(container, rules_keys)
|
42
41
|
true
|
43
42
|
end
|
44
43
|
|
45
44
|
def filter_simple_navigation_with_rules!(simple_navigation_item_container, keys)
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
45
|
+
unless keys==:all
|
46
|
+
simple_navigation_item_container.items.delete_if do |simple_navigation_item|
|
47
|
+
if keys.include?(simple_navigation_item.key.to_s)
|
48
|
+
sub_navigation = simple_navigation_item.sub_navigation
|
49
|
+
filter_simple_navigation_with_rules!(sub_navigation, keys) if sub_navigation
|
50
|
+
false
|
51
|
+
else
|
52
|
+
true
|
53
|
+
end
|
53
54
|
end
|
54
55
|
end
|
55
56
|
end
|