bali 2.1.1 → 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.md +5 -0
- data/lib/bali/dsl/rules_for_dsl.rb +16 -17
- data/lib/bali/foundations/exceptions/authorization_error.rb +2 -0
- data/lib/bali/objector.rb +4 -3
- data/lib/bali/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZGNkMWUxZjYxNjc3ODBiNzk5ODI4ZWFhMTM3NTgyOGU0MzAzNTZkNA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OWU3MjVhNjYwM2U0YTM4YWFjZDBkNDRlOGE0MTM1MzVlMDdkZDNiNg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OGY3ZDhiNTNlNDEzZGMxZmIyNDIyM2E5NmRkZjY1MGI2N2ZiOTE2ZDU0NTIz
|
10
|
+
ZmZhMjMwZTE5NTg4NTM1MjUxOGM0OTNkZTc4NDNiZDdiODBlYzY3MWZkZTIx
|
11
|
+
YTJkZGNlODA4ZTAyMzk5YThkZmNlNWNmMGYzMDJhZjA4MzE5OTg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MTY1NDQ1MzRiOTRlZjhiNmRiYTZhNjM4MmFjODVlYjg5YzkzZDE4Yzk3Nzlk
|
14
|
+
MWVmODIwM2ZjMDFhYTE0YmM5NDMwODI2Y2RmYmJkNTA4Y2JlYjliZGZiYjY5
|
15
|
+
ZjhhZmFkMmVmMTdjODkyNmUyMTBkOTMwOTAzYWQ4OWYzYmZmNjk=
|
data/CHANGELOG.md
CHANGED
@@ -67,3 +67,8 @@
|
|
67
67
|
|
68
68
|
1. Bug fixes on `clear_rules` which it clear rules defined in `others` even when not asked to
|
69
69
|
2. Bug fixes on `Bali::Printer` where inherited rules print the wrong target class due to another bug in an internal file (but doesn't hamper rules-checking logic)
|
70
|
+
|
71
|
+
== Version 2.1.2
|
72
|
+
|
73
|
+
1. `nil` will be printed <nil> when objecting with can! or cannot! for better readability.
|
74
|
+
2. Bug fixes on declaring multiple rules with decider. Previously, others were ignored--now, every single rule will get defined whether decider is present or not.
|
@@ -101,33 +101,32 @@ class Bali::RulesForDsl
|
|
101
101
|
end # others
|
102
102
|
|
103
103
|
# to define can and cant is basically using this method
|
104
|
-
def bali_process_auth_rules(auth_val,
|
104
|
+
def bali_process_auth_rules(auth_val, args)
|
105
105
|
conditional_hash = nil
|
106
|
+
operations = []
|
106
107
|
|
107
|
-
# scan
|
108
|
-
|
108
|
+
# scan args for options
|
109
|
+
args.each do |elm|
|
109
110
|
if elm.is_a?(Hash)
|
110
111
|
conditional_hash = elm
|
112
|
+
else
|
113
|
+
operations << elm
|
111
114
|
end
|
112
115
|
end
|
113
116
|
|
114
|
-
|
115
|
-
|
117
|
+
# add operation one by one
|
118
|
+
operations.each do |op|
|
116
119
|
rule = Bali::Rule.new(auth_val, op)
|
117
|
-
if conditional_hash
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
120
|
+
if conditional_hash
|
121
|
+
if conditional_hash[:if] || conditional_hash["if"]
|
122
|
+
rule.decider = conditional_hash[:if] || conditional_hash["if"]
|
123
|
+
rule.decider_type = :if
|
124
|
+
elsif conditional_hash[:unless] || conditional_hash[:unless]
|
125
|
+
rule.decider = conditional_hash[:unless] || conditional_hash["unless"]
|
126
|
+
rule.decider_type = :unless
|
127
|
+
end
|
123
128
|
end
|
124
129
|
self.current_rule_group.add_rule(rule)
|
125
|
-
else
|
126
|
-
# no conditional hash, proceed adding operations one by one
|
127
|
-
operations.each do |op|
|
128
|
-
rule = Bali::Rule.new(auth_val, op)
|
129
|
-
self.current_rule_group.add_rule(rule)
|
130
|
-
end
|
131
130
|
end
|
132
131
|
end # bali_process_auth_rules
|
133
132
|
|
@@ -12,6 +12,8 @@ class Bali::AuthorizationError < Bali::Error
|
|
12
12
|
attr_accessor :target
|
13
13
|
|
14
14
|
def to_s
|
15
|
+
# better error message for nil, so that it won't be empty
|
16
|
+
role = self.role ? self.role : "<nil>"
|
15
17
|
"Role #{role} is performing #{operation} using precedence #{auth_level}"
|
16
18
|
end
|
17
19
|
end
|
data/lib/bali/objector.rb
CHANGED
@@ -98,13 +98,14 @@ module Bali::Objector::Statics
|
|
98
98
|
break
|
99
99
|
elsif deducted_roles.is_a?(Array)
|
100
100
|
break
|
101
|
-
else
|
102
|
-
# keep it nil if _subtarget_roles is not either String, Symbol or Array
|
103
|
-
deducted_roles = nil
|
104
101
|
end
|
105
102
|
end # if matching class
|
106
103
|
end # each TRANSLATED_SUBTARGET_ROLES
|
107
104
|
|
105
|
+
if deducted_roles.nil?
|
106
|
+
raise Bali::AuthorizationError, "Bali does not know how to process roles: #{_subtarget_roles}"
|
107
|
+
end
|
108
|
+
|
108
109
|
return deducted_roles
|
109
110
|
end # if
|
110
111
|
end
|
data/lib/bali/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bali
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Pahlevi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|