petergate 1.1.4 → 1.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/lib/petergate/version.rb +1 -1
- data/lib/petergate.rb +6 -5
- 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: 9870e63e4c8df09757f73d8cb3823aa0058658ab
|
4
|
+
data.tar.gz: 6fb59869819c52e37e8af74cab872281a15f802c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7bff3ef1ef69d60507351573a1258a59de4fb5e252408f81a18854834f767bc55f9e1c037b2d784ac6509316fcc9bf158231922ca261b9364229c4cbdb4c206f
|
7
|
+
data.tar.gz: 42bc0b655c4f31a50257e1e5903aa20fe6b14a5ba2581a9869f5ec17175f433e544f5bb862f18d57588813935bbba89a6c323653be1fa78d12c3ea932755b39c
|
data/README.md
CHANGED
@@ -5,9 +5,10 @@
|
|
5
5
|
[![Gem Version](https://badge.fury.io/rb/petergate.svg)](http://badge.fury.io/rb/petergate)
|
6
6
|
|
7
7
|
|
8
|
-
> "
|
8
|
+
> "It's magnificent!
|
9
|
+
> If you like the straight forward and effective nature of [Strong Parameters](https://github.com/rails/strong_parameters) and suspect that [cancan](https://github.com/ryanb/cancan) might be overkill for your project then you'll love [Petergate's](https://github.com/isaacsloan/petergate) easy to use and read action and content based authorizations."
|
9
10
|
>
|
10
|
-
> -- <cite>
|
11
|
+
> -- <cite>1 Peter 3:41</cite>
|
11
12
|
|
12
13
|
Installation
|
13
14
|
------
|
data/lib/petergate/version.rb
CHANGED
data/lib/petergate.rb
CHANGED
@@ -14,11 +14,11 @@ module Petergate
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def all_actions
|
17
|
-
->{self.action_methods.to_a.map(&:to_sym) - [:check_access, :title]}
|
17
|
+
->{self.action_methods.to_a.map(&:to_sym) - [:check_access, :title]}.call
|
18
18
|
end
|
19
19
|
|
20
20
|
def except_actions(arr = [])
|
21
|
-
|
21
|
+
all_actions - arr
|
22
22
|
end
|
23
23
|
|
24
24
|
def access(rules = {}, &block)
|
@@ -66,9 +66,9 @@ module Petergate
|
|
66
66
|
rules = rules.inject({}) do |h, (k, v)|
|
67
67
|
special_values = case v.class.to_s
|
68
68
|
when "Symbol"
|
69
|
-
v == :all ? self.
|
69
|
+
v == :all ? self.class.all_actions : raise("No action for: #{v}")
|
70
70
|
when "Hash"
|
71
|
-
v[:except].present? ?
|
71
|
+
v[:except].present? ? self.class.except_actions(v[:except]) : raise("Invalid values for except: #{v.values}")
|
72
72
|
when "Array"
|
73
73
|
v
|
74
74
|
else
|
@@ -103,7 +103,8 @@ module Petergate
|
|
103
103
|
respond_to do |format|
|
104
104
|
format.any(:js, :json, :xml) { render nothing: true, status: :forbidden }
|
105
105
|
format.html do
|
106
|
-
|
106
|
+
destination = current_user.present? ? request.referrer || after_sign_in_path_for(current_user) : root_path
|
107
|
+
redirect_to destination, notice: msg || 'Permission Denied'
|
107
108
|
end
|
108
109
|
end
|
109
110
|
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.
|
4
|
+
version: 1.1.6
|
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-
|
11
|
+
date: 2015-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|