banken 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c0165126f4ba4d74766ee5eb58d91dc7ff2da97c
4
- data.tar.gz: 3033cd6c9f9d63a93413f0bc89f0e748b708d124
3
+ metadata.gz: 4faea250e6de5c7022b73be747b18978e4569a1e
4
+ data.tar.gz: fe8b0f64b93b370f9beaa04ea581180a4d2b3760
5
5
  SHA512:
6
- metadata.gz: ddba855ceb965c1c720a8b8a0d308285284510cf98d383ab4e7737fe79bc97235e9fd133400628887233a70a64d68b7b42a98157ebb3b95c1f8ea55cd87362bd
7
- data.tar.gz: 6db1afc5300330a1ddb09a186a7bc1beea908cf6491b123c61a1593173ebfe449a10c6fe06abea41d711144fce51264ab8a396339da4f021bf342f997be38ffe
6
+ metadata.gz: 49a1116ac331febca898385de35fcd0c518840cb3eab76cca7e266c99832f19572063573d8f6d3b9f18c97271885091d636594429d1ffbcbb22d44c82cfb1ae7
7
+ data.tar.gz: 711723dd4d3c2118624d7dca4bcaaeddef0bf203c30c063d18833df70644495634984da76196bddd6c68b685c5f7e3a232e55c808c0e5f9c672e9e6414fa6c64
@@ -2,7 +2,7 @@ language: ruby
2
2
  sudo: false
3
3
  script: "bundle exec rake"
4
4
  rvm:
5
- - 2.0.0
6
- - 2.1.5
7
- - 2.2.3
8
- - rbx-2
5
+ - 2.3.8
6
+ - 2.4.5
7
+ - 2.5.3
8
+ - 2.6.0
@@ -0,0 +1,3 @@
1
+ ## 1.0.3 (2019-01-14)
2
+
3
+ * Renamed `banken_loyalty_authorized?` to `banken_authorization_performed?` (okuramasafumi)
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- <img width="350"src="https://raw.github.com/wiki/kyuden/banken/images/banken.png">
1
+ <img width="350" src="https://raw.github.com/wiki/kyuden/banken/images/banken.png">
2
2
 
3
3
  [![Build Status](https://img.shields.io/travis/kyuden/banken/master.svg)](https://travis-ci.org/kyuden/banken)
4
4
  [![Code Climate](https://codeclimate.com/github/kyuden/banken/badges/gpa.svg)](https://codeclimate.com/github/kyuden/banken)
@@ -157,6 +157,16 @@ conditionally showing links or buttons in the view:
157
157
  <% end %>
158
158
  ```
159
159
 
160
+ If you are using namespace in your controller and policy,
161
+ you can access the policy passing string like 'admin/posts' as a second argument.
162
+ Below calls Admin::PostsLoyalty.
163
+
164
+ ``` erb
165
+ <% if loyalty(@post, 'admin/posts').update? %>
166
+ <%= link_to "Edit post", edit_post_path(@post) %>
167
+ <% end %>
168
+ ```
169
+
160
170
  ## Ensuring loyalties are used
161
171
 
162
172
  Banken adds a method called `verify_authorized` to your controllers. This
@@ -192,7 +202,7 @@ end
192
202
  ```
193
203
 
194
204
  If you need to perform some more sophisticated logic or you want to raise a custom
195
- exception you can use the two lower level method `banken_loyalty_authorized?` which
205
+ exception you can use the two lower level method `banken_authorization_performed?` which
196
206
  return `true` or `false` depending on whether `authorize!` have been called, respectively.
197
207
 
198
208
  ## Just plain old Ruby
@@ -31,7 +31,7 @@ module Banken
31
31
  end
32
32
 
33
33
  def authorize!(record=nil)
34
- @_banken_loyalty_authorized = true
34
+ @_banken_authorization_performed = true
35
35
 
36
36
  loyalty = loyalty(record)
37
37
  unless loyalty.public_send(banken_query_name)
@@ -56,15 +56,21 @@ module Banken
56
56
  end
57
57
 
58
58
  def skip_authorization
59
- @_banken_loyalty_authorized = true
59
+ @_banken_authorization_performed = true
60
60
  end
61
61
 
62
62
  def verify_authorized
63
- raise AuthorizationNotPerformedError unless banken_loyalty_authorized?
63
+ raise AuthorizationNotPerformedError unless banken_authorization_performed?
64
64
  end
65
65
 
66
+ def banken_authorization_performed?
67
+ !!@_banken_authorization_performed
68
+ end
69
+
70
+ # @deprecated Use banken_authorization_performed? instead.
66
71
  def banken_loyalty_authorized?
67
- !!@_banken_loyalty_authorized
72
+ ActiveSupport::Deprecation.warn('banken_loyalty_authorized? is deprecated, use banken_authorization_performed? instead.')
73
+ banken_authorization_performed?
68
74
  end
69
75
 
70
76
  private
@@ -2,10 +2,10 @@ module Banken
2
2
  class LoyaltyFinder
3
3
  SUFFIX = "Loyalty"
4
4
 
5
- attr_reader :controller
5
+ attr_reader :controller_name
6
6
 
7
- def initialize(controller)
8
- @controller = controller.to_s
7
+ def initialize(controller_name)
8
+ @controller_name = controller_name.to_s
9
9
  end
10
10
 
11
11
  def loyalty
@@ -15,14 +15,13 @@ module Banken
15
15
  end
16
16
 
17
17
  def loyalty!
18
- raise NotDefinedError, "unable to find loyalty of nil" unless controller
19
- loyalty || raise(NotDefinedError, "unable to find loyalty `#{loyalty_name}` for `#{controller}`")
18
+ loyalty || raise(NotDefinedError, "unable to find loyalty `#{loyalty_name}` for `#{controller_name}`")
20
19
  end
21
20
 
22
21
  private
23
22
 
24
23
  def loyalty_name
25
- "#{controller.camelize}#{SUFFIX}"
24
+ "#{controller_name.camelize}#{SUFFIX}"
26
25
  end
27
26
  end
28
27
  end
@@ -1,3 +1,3 @@
1
1
  module Banken
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: banken
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - kyuden
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-29 00:00:00.000000000 Z
11
+ date: 2019-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -133,6 +133,7 @@ files:
133
133
  - ".gitignore"
134
134
  - ".rspec"
135
135
  - ".travis.yml"
136
+ - CHANGELOG.md
136
137
  - CODE_OF_CONDUCT.md
137
138
  - Gemfile
138
139
  - LICENSE.txt
@@ -169,9 +170,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
170
  version: '0'
170
171
  requirements: []
171
172
  rubyforge_project:
172
- rubygems_version: 2.4.5.1
173
+ rubygems_version: 2.6.11
173
174
  signing_key:
174
175
  specification_version: 4
175
176
  summary: Simple and lightweight authorization solution for Rails.
176
177
  test_files: []
177
- has_rdoc: