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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e874f558d2dba4491ce0df91cd9dd14d97169abd
4
- data.tar.gz: 5068a8370ec69a9797af8ccb27b3001a2ecd21a7
3
+ metadata.gz: 8fa3c73c0f112d28500fcbcb241a152643853a5e
4
+ data.tar.gz: c93c7d0652127f3ae3542e9bc7b09e6445fef36d
5
5
  SHA512:
6
- metadata.gz: b26024de4dd6f9a8f5dd223c576be77001bb717a3193dcd17c558d7e4cba65efa5b0160883b192c1ec9f863beb8c943ac91a30dd95332e96c3827328111b1d3d
7
- data.tar.gz: 10b62d0f11bdc6696152e5092f0be7ff562eca0f21a8000bc44a56e38895d75353d298209561d07d99854d31fade1ed314a62df21eac8307ba95388ca7ac6747
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
- when "Array"
75
- v
76
- else
77
- raise("No action for: #{v}")
78
- end
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(options = {roles: [:admin]})
10
- serialize :roles
11
- after_initialize do
12
- self[:roles] ||= []
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', options[: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
- def roles=(v)
26
- self[:roles] = Array(v).map(&:to_sym).to_a.select{|r| r.size > 0 && available_roles.include?(r)}
27
- end
28
-
29
- def roles
30
- self[:roles] + [:user]
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
@@ -1,3 +1,3 @@
1
1
  module Petergate
2
- VERSION = "1.1.8"
2
+ VERSION = "1.2.0"
3
3
  end
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.1.8
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-13 00:00:00.000000000 Z
11
+ date: 2015-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler