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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OGE5M2M0ZmE1MGJmMDc4M2ZmM2Q3NzlkNGY3OTAxMDUzNGEwYTBiNg==
4
+ ZGNkMWUxZjYxNjc3ODBiNzk5ODI4ZWFhMTM3NTgyOGU0MzAzNTZkNA==
5
5
  data.tar.gz: !binary |-
6
- NmQ0MGNkOGRiMjJlZjc1YTFmZmMzN2FjNDNiNTU1N2I3OTZkZjMyYg==
6
+ OWU3MjVhNjYwM2U0YTM4YWFjZDBkNDRlOGE0MTM1MzVlMDdkZDNiNg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NWUxZDA3YmFkMDI1YzIwMDUzMjdmNTIxNjBhZmZjNTZmNzc3NWUxMjNmNDU4
10
- MmYzNDgxNzczZjc1ODcxMDU0N2FkN2U0ZDM0NDhmYzI1NzY5N2ZjZTAyZGY1
11
- MTBiYTQ1ZjU2ZjhhNmUxNjZhZjJkYWM1NTk1Yzk4ZDAyNjM2OWM=
9
+ OGY3ZDhiNTNlNDEzZGMxZmIyNDIyM2E5NmRkZjY1MGI2N2ZiOTE2ZDU0NTIz
10
+ ZmZhMjMwZTE5NTg4NTM1MjUxOGM0OTNkZTc4NDNiZDdiODBlYzY3MWZkZTIx
11
+ YTJkZGNlODA4ZTAyMzk5YThkZmNlNWNmMGYzMDJhZjA4MzE5OTg=
12
12
  data.tar.gz: !binary |-
13
- NWUwZTM5NTA5NGFiZDI3NDgxMGM5YTlkYzM2Mzc0Y2NjM2IyMmZiYTNiODFh
14
- NWMzMzMzZjgyY2QyZWM4MTc1YzdlNGI0NmE0YzM3YmZjNTg4M2I0OWFmZTAw
15
- MWE0Mzk4OWY3YzI2NTVhZjIxOGNkYWRjOGE0NzhiMzYzZWQ2NjE=
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, operations)
104
+ def bali_process_auth_rules(auth_val, args)
105
105
  conditional_hash = nil
106
+ operations = []
106
107
 
107
- # scan operations for options
108
- operations.each do |elm|
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
- if conditional_hash
115
- op = operations[0]
117
+ # add operation one by one
118
+ operations.each do |op|
116
119
  rule = Bali::Rule.new(auth_val, op)
117
- if conditional_hash[:if] || conditional_hash["if"]
118
- rule.decider = conditional_hash[:if] || conditional_hash["if"]
119
- rule.decider_type = :if
120
- elsif conditional_hash[:unless] || conditional_hash[:unless]
121
- rule.decider = conditional_hash[:unless] || conditional_hash["unless"]
122
- rule.decider_type = :unless
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
@@ -1,3 +1,3 @@
1
1
  module Bali
2
- VERSION = "2.1.1"
2
+ VERSION = "2.1.2"
3
3
  end
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.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-09-26 00:00:00.000000000 Z
11
+ date: 2015-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler