guachiman 0.1.4 → 0.1.5

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: 7e6fd56b0aa9fdbd47edc2287ce0a09e82796663
4
- data.tar.gz: 7bb8f254b756e24f05e60b37075ee10b7bf70226
3
+ metadata.gz: 9bb434953ea5c8ab561240736018d69cae694358
4
+ data.tar.gz: e3842d89ba4ddb628c6bd0d65ca21f539ebd9e9b
5
5
  SHA512:
6
- metadata.gz: ecbda870fdeefee6d215a52b74407e05d0f40b35dc494426095cb6899e55fc076f7af5ec4d853dcb6f7163f4ba18ddf6126fdcd3a77d4ac39c22e1012180f304
7
- data.tar.gz: b9df6b3ecacdcc7060c17284b83dbbe5a56ea5bbe2b8c8f2a873c42c94a34f78e9167066cbafa2d16d539e36ad705bd025c15cf7cbc003a9ce95ab2edec08ff6
6
+ metadata.gz: 91d00a9cd7e4cf285dd466ccb265074b46872a966b5bd20afb7ced75fa305de79a0f60d194ab0f61b5c9c165459a989f00364eaad25e66a2bfeedf8d40c00f8d
7
+ data.tar.gz: c2573c47d188a6ad7f9c3e90ca9bd5316b8be9b26f044c73c2886c9ca288b46fc810af13f5aa6c5a1261a27a51c283b7a86d1a7149755d5213110d1f66cdfed9
data/README.md CHANGED
@@ -30,7 +30,7 @@ Usage
30
30
 
31
31
  Run `rails g guachiman:install`
32
32
 
33
- This will generate a `Permission.rb` file in `app/models`.
33
+ This will generate a `permission.rb` file in `app/models`.
34
34
 
35
35
  Include `Guachiman::Permissible` in `ApplicationController` and implemente a `current_user` method there.
36
36
 
@@ -51,7 +51,7 @@ end
51
51
 
52
52
  def not_signed_in
53
53
  session[:next] = request.url
54
- redirect_to sign_in_path, alert: t('flashes.please_login')
54
+ redirect_to sign_in_path, alert: t('flashes.please_sign_in')
55
55
  end
56
56
  ```
57
57
 
@@ -62,10 +62,11 @@ class Permission
62
62
  include Guachiman::Permissions
63
63
  include Guachiman::Params
64
64
 
65
- attr_reader :user
65
+ attr_reader :user, :request
66
66
 
67
- def initialize current_user
68
- @user = current_user
67
+ def initialize current_user, current_request
68
+ @user = current_user
69
+ @request = current_request
69
70
 
70
71
  if user.nil?
71
72
  guest
@@ -100,4 +101,4 @@ end
100
101
 
101
102
  * `allow` takes a controller params key and an array of actions.
102
103
  * `allow_param` takes a model params key and an array of attributes.
103
- * `allow_all!` is a convinience method to allow all controlles, actions and parameteres.
104
+ * `allow_all!` is a convinience method to allow all controlles, actions and parameteres.
@@ -2,7 +2,12 @@ class Permission
2
2
  include Guachiman::Permissions
3
3
  include Guachiman::Params
4
4
 
5
- def initialize user
5
+ attr_reader :user, :request
6
+
7
+ def initialize current_user, current_request
8
+ @user = current_user
9
+ @request = current_request
10
+
6
11
  if user.nil?
7
12
  guest
8
13
  elsif user.admin?
@@ -13,7 +13,7 @@ module Guachiman
13
13
  end
14
14
 
15
15
  def current_permission
16
- @current_permission ||= Permission.new current_user
16
+ @current_permission ||= Permission.new current_user, request
17
17
  end
18
18
 
19
19
  def current_resource
@@ -1,3 +1,3 @@
1
1
  module Guachiman
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end
@@ -24,7 +24,7 @@ class InstallGeneratorTest < Rails::Generators::TestCase
24
24
  assert_match /class Permission/, f
25
25
  assert_match /include Guachiman::Permissions/, f
26
26
  assert_match /include Guachiman::Params/, f
27
- assert_match /initialize user/, f
27
+ assert_match /initialize current_user/, f
28
28
  end
29
29
  end
30
30
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guachiman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francesco Rodriguez
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-09 00:00:00.000000000 Z
12
+ date: 2013-09-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
@@ -154,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
154
  version: '0'
155
155
  requirements: []
156
156
  rubyforge_project:
157
- rubygems_version: 2.0.3
157
+ rubygems_version: 2.0.6
158
158
  signing_key:
159
159
  specification_version: 4
160
160
  summary: Basic authorization library