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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 258e0ba6e9d58cf4d45228e19508f7ce450a3953
4
- data.tar.gz: b894cb1c27571894af39a308e171fc3bfafdc99f
3
+ metadata.gz: df435f64ec3d897e435b2292f0708c2908cec6f0
4
+ data.tar.gz: fec3495f222f0f7ddc07d4e35326c2331dc766c1
5
5
  SHA512:
6
- metadata.gz: 2a0a718d91254cc1bc64908f4b0e746cdefbdaf5e336ee01eb4d1cb2e709420b6bd822466ad73419596820c089a79bc5071026e9be6ea6645a2871da28cb48d8
7
- data.tar.gz: 359f33ab68954463098ec4688053ad77b3868e3cec02e8ef6581339a264e3fa0175c7c031d8220a57c90efca55a6f6dbc56de87467e8d972dc66f0b77878303b
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: [:index, :edit]
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]
@@ -1,8 +1,5 @@
1
- require 'pundit_extra/helpers'
2
- require 'pundit_extra/resource_autoload'
3
-
4
1
  module PunditExtra
5
- def self.included(base)
2
+ def self.included(_base)
6
3
  if defined? ActionController::Base
7
4
  ActionController::Base.class_eval do
8
5
  include PunditExtra::Helpers
@@ -9,7 +9,7 @@ module PunditExtra
9
9
  end
10
10
 
11
11
  def cannot?(*args)
12
- !can? *args
12
+ !can?(*args)
13
13
  end
14
14
  end
15
15
  end
@@ -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
- skip_authorization
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
@@ -1,3 +1,3 @@
1
1
  module PunditExtra
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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.0
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-09 00:00:00.000000000 Z
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
  - - "~>"