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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8fa3c73c0f112d28500fcbcb241a152643853a5e
4
- data.tar.gz: c93c7d0652127f3ae3542e9bc7b09e6445fef36d
3
+ metadata.gz: 9b892f7fb8bd9dede52439d388ad0960785eda65
4
+ data.tar.gz: 64e30d9978358748a8755419b5b06521fe856c05
5
5
  SHA512:
6
- metadata.gz: 477ec56213cfb10f13be43082c361b7453d1ad5f4d7da5b77324f537a3a40bbdb1f69d52a6114b48c5a63cee8db6a679ee0f3e2d658d98b020337b21b8b4d308
7
- data.tar.gz: 9697d0099f63d92e3548a575602cf0179b7dfc74505b2ae06729262f54fff7cd71c222e0e7b744df99d727902c4975e767e44e17f3b2d25a7943f2f7a29b2622
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
- > "It's magnificent!
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
- 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
@@ -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
- case params[:action].to_sym
89
- when *(rules[:all]) # checks where the action can be seen by :all
90
- true
91
- when *(rules[:user]) # checks if the action can be seen for all users
92
- user_signed_in?
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)
@@ -1,3 +1,3 @@
1
1
  module Petergate
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.1"
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.2.0
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: 2015-08-14 00:00:00.000000000 Z
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.