petergate 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/petergate/action_controller/base.rb +10 -15
- data/lib/petergate/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b892f7fb8bd9dede52439d388ad0960785eda65
|
4
|
+
data.tar.gz: 64e30d9978358748a8755419b5b06521fe856c05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00262c0fdb48c9b50dd12814be378b6342d71001e71d6ed0022d33640e10d53e1d675db7ef59c45deeeec0ada3393b53072d963a23d460197b0e28c4f90093ba
|
7
|
+
data.tar.gz: 76b3390ab9851e4791a8de4bedee17b3323e85b13813ac5bfc11838dd23c44c01472ef44fa152f4ff00c4a2d8cf0e5455e1a69891f9eb69d45e4ed4f6ac308cb
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
[![Gem Version](https://badge.fury.io/rb/petergate.svg)](http://badge.fury.io/rb/petergate)
|
6
6
|
|
7
7
|
|
8
|
-
|
8
|
+
|
9
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."
|
10
10
|
>
|
11
11
|
> -- <cite>1 Peter 3:41</cite>
|
@@ -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
|
@@ -85,16 +85,11 @@ module Petergate
|
|
85
85
|
|
86
86
|
def permissions(rules = {all: [:index, :show], customer: [], wiring: []})
|
87
87
|
rules = parse_permission_rules(rules)
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
when *(rules[(user_signed_in? ? current_user.role.to_sym : :all)]) # checks if action can be seen by the current_users role. If the user isn't logged in check if it can be seen by :all
|
94
|
-
true
|
95
|
-
else
|
96
|
-
false
|
97
|
-
end
|
88
|
+
allowances = [rules[:all]]
|
89
|
+
current_user.roles.each do |role|
|
90
|
+
allowances << rules[role]
|
91
|
+
end if logged_in?(:user)
|
92
|
+
allowances.flatten.compact.include?(params[:action].to_sym)
|
98
93
|
end
|
99
94
|
|
100
95
|
def logged_in?(*roles)
|
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.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Isaac Sloan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -96,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
96
|
version: '0'
|
97
97
|
requirements: []
|
98
98
|
rubyforge_project:
|
99
|
-
rubygems_version: 2.4.5
|
99
|
+
rubygems_version: 2.4.5.1
|
100
100
|
signing_key:
|
101
101
|
specification_version: 4
|
102
102
|
summary: Authorization system allowing verbose easy read controller syntax.
|