pundit_extra 0.1.0 → 0.1.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 +18 -1
- data/lib/pundit_extra/controller_mixin.rb +1 -4
- data/lib/pundit_extra/helpers.rb +1 -1
- data/lib/pundit_extra/resource_autoload.rb +5 -7
- data/lib/pundit_extra/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df435f64ec3d897e435b2292f0708c2908cec6f0
|
4
|
+
data.tar.gz: fec3495f222f0f7ddc07d4e35326c2331dc766c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a65374449905de751559da4c65a661218033240694de04e2afe34ed78d6d776061e2645e387f044f1a062f0d26b1cd3e796514a06acb539c3d7138d1bb6527e5
|
7
|
+
data.tar.gz: 732d987ee1b6376c280e7889158b67b8eb2f57132b2af3de133b4d5ae4672bf4fa70a2d4d2ea98f9c328cc224e57d0103f015b5be73905e6da3fb80ac4c6ccde
|
data/README.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# PunditExtra
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/pundit_extra.svg)](http://badge.fury.io/rb/pundit_extra)
|
4
|
+
[![Build Status](https://travis-ci.org/DannyBen/pundit_extra.svg?branch=master)](https://travis-ci.org/DannyBen/pundit_extra)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/DannyBen/pundit_extra/badges/gpa.svg)](https://codeclimate.com/github/DannyBen/pundit_extra)
|
6
|
+
[![Dependency Status](https://gemnasium.com/DannyBen/pundit_extra.svg)](https://gemnasium.com/DannyBen/pundit_extra)
|
7
|
+
|
3
8
|
This library borrows functionality from [CanCan(Can)][2] and adds it to [Pundit][1].
|
4
9
|
|
5
10
|
- `can?` and `cannot?` view helpers
|
@@ -62,9 +67,14 @@ Example:
|
|
62
67
|
```ruby
|
63
68
|
class TasksController < ApplicationController
|
64
69
|
before_action :authenticate_user!
|
65
|
-
load_resource except: [:
|
70
|
+
load_resource except: [:edit, :complete]
|
66
71
|
authorize_resource except: :index
|
67
72
|
|
73
|
+
def index
|
74
|
+
# this happens automatically
|
75
|
+
# @tasks = policy_scope(Task)
|
76
|
+
end
|
77
|
+
|
68
78
|
def show
|
69
79
|
# this happens automatically
|
70
80
|
# @task = Task.find params[:id]
|
@@ -86,6 +96,13 @@ class TasksController < ApplicationController
|
|
86
96
|
end
|
87
97
|
```
|
88
98
|
|
99
|
+
In addition, you can use:
|
100
|
+
|
101
|
+
- `load_and_authorize_resource` which is a combination shortcut for
|
102
|
+
`load_resource` and `authorize_resource`
|
103
|
+
- `skip_authorization` which sends `skip_authorization` and
|
104
|
+
`skip_policy_scope` to Pundit for all (or the specified) actions.
|
105
|
+
|
89
106
|
## Credits
|
90
107
|
|
91
108
|
- [Jonas Nicklas](https://github.com/jnicklas) @ [Pundit][1]
|
data/lib/pundit_extra/helpers.rb
CHANGED
@@ -18,8 +18,10 @@ module PunditExtra
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def load_and_authorize_resource(options={})
|
21
|
+
# :nocov:
|
21
22
|
load_resource options
|
22
23
|
authorize_resource options
|
24
|
+
# :nocov:
|
23
25
|
end
|
24
26
|
end
|
25
27
|
|
@@ -48,12 +50,8 @@ module PunditExtra
|
|
48
50
|
|
49
51
|
def skip_authorization_and_scope
|
50
52
|
action = params[:action]
|
51
|
-
if action == 'index'
|
52
|
-
|
53
|
-
skip_policy_scope
|
54
|
-
else
|
55
|
-
skip_authorization
|
56
|
-
end
|
53
|
+
skip_policy_scope if action == 'index'
|
54
|
+
skip_authorization
|
57
55
|
end
|
58
56
|
|
59
57
|
def resource_name
|
@@ -68,4 +66,4 @@ module PunditExtra
|
|
68
66
|
instance_variable_get "@#{resource_name}"
|
69
67
|
end
|
70
68
|
end
|
71
|
-
end
|
69
|
+
end
|
data/lib/pundit_extra/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pundit_extra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danny Ben Shitrit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: combustion
|
@@ -40,6 +40,20 @@ dependencies:
|
|
40
40
|
version: '0.5'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: run-gem-dev
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: runfile-exec
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
59
|
- - "~>"
|