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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fdb8332bcf728cb3dc6929fd66efc3c14c9ae075
4
- data.tar.gz: f2f2f3bf37a53df4b321bf7c6c4e02148f7e390b
3
+ metadata.gz: dc76fec314ad4e65a068e25567468ad9b33492c7
4
+ data.tar.gz: 9eb44ab803b6bd46c7526590d7099f94e2b48a12
5
5
  SHA512:
6
- metadata.gz: 676dccb0ab8b820259e1f4cc73bfb35573edc5fefcbad4f22ed2a2265bc76d84d3b582829e9985102c9288916ac76a47d7166212704608adb4944ca7e7c3335b
7
- data.tar.gz: ec854928da332e87c2c61a65c3eb8a7a4cb975e2167250e19279d9ff2e2a4a41410bc5dbcac3b6a3cf2e5b1117659a34a05f88b0cfd9d39d92207db91fddfcc4
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.pluck(:key))
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
- 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
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
@@ -1,3 +1,3 @@
1
1
  module SimpleNavigationAcl
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple-navigation-acl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bruno Porto