sanction 2.1.0 → 2.1.1

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: 0d9b7c911e6b858db458af6c2a1a1a2576831c6c
4
- data.tar.gz: dfc5c0aa9ea471972fb4897649e195195b8d4002
3
+ metadata.gz: 54b4bc26ea4486d4933609a99ce9069cc9d0e006
4
+ data.tar.gz: 61e47caeb74f34362da54ca9e4fc4795502e0141
5
5
  SHA512:
6
- metadata.gz: 627ca53b8f5c5d2d162b4035e792f94af8560e6f66cb6ab4030db8a646ccb909a9078a28c3e7d16c6f59254a3ef03cffd61c2fd9d38f48db93ea4b2ee550e7ed
7
- data.tar.gz: 31e827b77feb6d04d471d54e08f260b833bf845d930fbab5cf401ecd4f2ea18d0936455d78f7c94c17fda1e043c673a30af6c6c094ac9653bf904165627b32b5
6
+ metadata.gz: eccc4a6e58d4c3db5ead80ef35479c329e64843eb6259096476a2c368b61cc902723ee917c3a6c5147ea94922fd1f0294f869d8abd1d451aa3287ccf8f09b656
7
+ data.tar.gz: e340fc3cb7f86837bf9bf2c5ff91206f7502dda29b0128da593e777de8ae863cefd5badf92d0617cfd91a9106618597761049444650c06f5667db67ca5ae7e21
@@ -13,6 +13,10 @@ module Sanction
13
13
  true
14
14
  end
15
15
 
16
+ def scope
17
+ permitted? ? super : []
18
+ end
19
+
16
20
  def deny!
17
21
  false
18
22
  end
data/lib/sanction/node.rb CHANGED
@@ -86,11 +86,21 @@ module Sanction
86
86
  end
87
87
 
88
88
  def scope
89
+ return @scope if (parent.blank? && root?)
89
90
  @scope.blank? ? parent.scope : @scope
90
91
  end
91
92
 
92
- def scope=(scope)
93
- @scope = [scope].flatten.compact.map(&:to_sym)
93
+ def scope=(attribute)
94
+ @scope = [attribute].flatten.compact.map(&:to_sym)
95
+ end
96
+
97
+ def add_scope(attribute)
98
+ @scope << attribute.to_sym
99
+ sanitize_scope!
100
+ end
101
+
102
+ def remove_scope(attribute)
103
+ @scope.reject! {|x| x == attribute.to_sym }
94
104
  end
95
105
 
96
106
  def resources
@@ -122,9 +132,13 @@ module Sanction
122
132
 
123
133
  private
124
134
 
135
+ def sanitize_scope!
136
+ @scope = @scope.flatten.compact.uniq.map(&:to_sym)
137
+ end
138
+
125
139
  def process_hash(hash)
126
140
  @id = hash[:id]
127
- @scope = hash[:scope].map(&:to_sym) unless hash[:scope].blank?
141
+ @scope = [hash[:scope]].flatten.compact.map(&:to_sym)
128
142
  @type = hash[:type].to_sym if hash[:type]
129
143
  @resources = []
130
144
  @resources += hash[:resources].map(&:to_sym) unless hash[:resources].blank?
@@ -1,3 +1,3 @@
1
1
  module Sanction
2
- VERSION = "2.1.0"
2
+ VERSION = "2.1.1"
3
3
  end
@@ -11,6 +11,10 @@ module Sanction
11
11
  false
12
12
  end
13
13
 
14
+ def scope
15
+ permitted? ? super : []
16
+ end
17
+
14
18
  def deny!
15
19
  @parent.resources << type
16
20
  @parent.resources.uniq!
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sanction
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Carlile
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-11-26 00:00:00.000000000 Z
12
+ date: 2015-01-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport