petergate 1.1.8 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/petergate/action_controller/base.rb +5 -5
- data/lib/petergate/active_record/base.rb +28 -11
- data/lib/petergate/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8fa3c73c0f112d28500fcbcb241a152643853a5e
|
4
|
+
data.tar.gz: c93c7d0652127f3ae3542e9bc7b09e6445fef36d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 477ec56213cfb10f13be43082c361b7453d1ad5f4d7da5b77324f537a3a40bbdb1f69d52a6114b48c5a63cee8db6a679ee0f3e2d658d98b020337b21b8b4d308
|
7
|
+
data.tar.gz: 9697d0099f63d92e3548a575602cf0179b7dfc74505b2ae06729262f54fff7cd71c222e0e7b744df99d727902c4975e767e44e17f3b2d25a7943f2f7a29b2622
|
@@ -71,11 +71,11 @@ module Petergate
|
|
71
71
|
v == :all ? self.class.all_actions : raise("No action for: #{v}")
|
72
72
|
when "Hash"
|
73
73
|
v[:except].present? ? self.class.except_actions(v[:except]) : raise("Invalid values for except: #{v.values}")
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
74
|
+
when "Array"
|
75
|
+
v
|
76
|
+
else
|
77
|
+
raise("No action for: #{v}")
|
78
|
+
end
|
79
79
|
|
80
80
|
h.merge({k => special_values})
|
81
81
|
end
|
@@ -6,14 +6,20 @@ module Petergate
|
|
6
6
|
end
|
7
7
|
|
8
8
|
module ClassMethods
|
9
|
-
def petergate(
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
def petergate(roles: [:admin], multiple: true)
|
10
|
+
if multiple
|
11
|
+
serialize :roles
|
12
|
+
after_initialize do
|
13
|
+
self[:roles] ||= [:user]
|
14
|
+
end
|
15
|
+
else
|
16
|
+
after_initialize do
|
17
|
+
self[:roles] ||= :user
|
18
|
+
end
|
13
19
|
end
|
14
20
|
|
15
21
|
instance_eval do
|
16
|
-
const_set('ROLES',
|
22
|
+
const_set('ROLES', (roles + [:user]).uniq)
|
17
23
|
end
|
18
24
|
|
19
25
|
|
@@ -22,12 +28,23 @@ module Petergate
|
|
22
28
|
self.class::ROLES
|
23
29
|
end
|
24
30
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
+
if multiple
|
32
|
+
def roles=(v)
|
33
|
+
self[:roles] = (Array(v).map(&:to_sym).select{|r| r.size > 0 && available_roles.include?(r)} + [:user]).uniq
|
34
|
+
end
|
35
|
+
else
|
36
|
+
def roles=(v)
|
37
|
+
self[:roles] = case v.class.to_s
|
38
|
+
when "String", "Symbol"
|
39
|
+
v
|
40
|
+
when "Array"
|
41
|
+
v.first
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def roles
|
46
|
+
Array(self[:roles].to_sym)
|
47
|
+
end
|
31
48
|
end
|
32
49
|
|
33
50
|
def role
|
data/lib/petergate/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: petergate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Isaac Sloan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|