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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7d882eeb3e09ea3404933ed107a6b1b477c13f1a
4
- data.tar.gz: e1325d7e46ca598219f47593bd82ad8193399574
3
+ metadata.gz: 9870e63e4c8df09757f73d8cb3823aa0058658ab
4
+ data.tar.gz: 6fb59869819c52e37e8af74cab872281a15f802c
5
5
  SHA512:
6
- metadata.gz: 7ef493c0db45b0a446619ebc3624904ce3a54b801affc26a2ddfd08351f314bb65d520e63080abed1d7eb2914fc40b18efe62c78d537d4bb8febac3a2e452ee0
7
- data.tar.gz: 0ffe29f07c7e46231033d4b8ab40967fc80866c5cfc0ffc898a6f5f30cf5fb1165c6d1e6995709b6b3e3394db72021289366da5223a77861475c355161e3c792
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
- > "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."
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>I proclaim optimistically</cite>
11
+ > -- <cite>1 Peter 3:41</cite>
11
12
 
12
13
  Installation
13
14
  ------
@@ -1,3 +1,3 @@
1
1
  module Petergate
2
- VERSION = "1.1.4"
2
+ VERSION = "1.1.6"
3
3
  end
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
- ->{all_actions.call - arr}
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.action_methods.to_a.map(&:to_sym) - [:check_access, :title] : raise("No action for: #{v}")
69
+ v == :all ? self.class.all_actions : raise("No action for: #{v}")
70
70
  when "Hash"
71
- v[:except].present? ? (self.action_methods.to_a.map(&:to_sym) - [:check_access, :title]) - v[:except] : raise("Invalid values for except: #{v.values}")
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
- redirect_to (request.referrer || after_sign_in_path_for(current_user)), notice: msg || 'Permission Denied'
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
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-03-05 00:00:00.000000000 Z
11
+ date: 2015-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler