admission 0.4.6 → 0.4.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: befc0b2727a31e8682bb8fa6cfcfa3f8d4d0bf34
4
- data.tar.gz: 153b1a50900695e12c029f980ace8ae31c836d84
3
+ metadata.gz: f03c5417670b97a8de57b5a1254e1152a2a159f5
4
+ data.tar.gz: 7fdb46a9dc899c36c592b6c7d920768f93ed0add
5
5
  SHA512:
6
- metadata.gz: ce09286c4eea2e6a7b77ae4ae8661f002d0ba3fd23b513062b1d180f69806d74b2f3edf945438e481a8c33e3ceda8a2a840881c7f04892069da451bc4c69a797
7
- data.tar.gz: 0b7182cbac9e7b5863a6d50900ebcaa59d94c948ee7581e936029dfbed890a9ce17226a4c3a56c52d06b8c5755c6a08af45acc605e4bd1ae46dc3daada3626d9
6
+ metadata.gz: a87e3b4e647e3bb83acc3edc42b0d22ad29550ab0a75bd0e37b393eb04138386579d0d69d85a786bd14c20fca7c78bcfdff94a07d8c74c0b664c530bd6f663f2
7
+ data.tar.gz: c381044a18429eaf0615fae7d2a0e98e2b8803bb75345e8a1091c4531d35da2cbc5214d934b338e5de207a7732620f64038152d293436208dfec010317e70ec4
@@ -11,4 +11,6 @@ class Admission::Denied < ::StandardError
11
11
  "Admission denied to #{arbitration.case_to_s}."
12
12
  end
13
13
 
14
+ alias to_s message
15
+
14
16
  end
@@ -7,19 +7,19 @@ class Admission::Index
7
7
  @children = {}
8
8
  end
9
9
 
10
- def allow *add_items, **add_children
10
+ def add *add_items, **add_children
11
11
  @items |= add_items.flatten.map(&:to_sym)
12
12
 
13
13
  add_children.each do |key, list|
14
- child = Admission::Index.new
15
- child.allow *list
14
+ child = @children[key] || Admission::Index.new
15
+ child.add *list
16
16
  children[key] = child
17
17
  end
18
18
 
19
19
  self
20
20
  end
21
21
 
22
- def allowed? *path
22
+ def include? *path
23
23
  item, *path = path
24
24
  item = item.to_sym
25
25
 
@@ -28,26 +28,26 @@ class Admission::Index
28
28
 
29
29
  else
30
30
  child = children[item]
31
- child ? child.allowed?(*path) : false
31
+ child ? child.include?(*path) : false
32
32
  end
33
33
  end
34
34
 
35
35
  def == other
36
36
  case other
37
37
  when Array
38
- to_a.eql? other
38
+ to_list.eql? other
39
39
  else
40
40
  super
41
41
  end
42
42
  end
43
43
  alias :eql? :==
44
44
 
45
- def to_a
45
+ def to_list
46
46
  result_list = items.dup
47
47
 
48
48
  unless children.empty?
49
49
  result_children = children.inject Hash.new do |h, (key, index)|
50
- h[key] = index.to_a
50
+ h[key] = index.to_list
51
51
  h
52
52
  end
53
53
  result_list.push result_children
@@ -1,3 +1,3 @@
1
1
  module Admission
2
- VERSION = '0.4.6'
2
+ VERSION = '0.4.9'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: admission
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6
4
+ version: 0.4.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ondřej Želazko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-18 00:00:00.000000000 Z
11
+ date: 2018-04-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Admission rules to actions or resources, privileges system included
14
14
  email: zelazk.o@email.cz