role_authorization 0.6.2 → 0.9.0

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: a8db6f0c4c6939b591b3637eb6d9fccf4c884460
4
- data.tar.gz: 3e226410d3e5f0541d6f18d9daf9987ed4f0f52d
3
+ metadata.gz: 6751fa8bb50a5e8ecb396698c237e73ead87cc49
4
+ data.tar.gz: 56457bb779d95347cf63f9991867d398c74b7e0f
5
5
  SHA512:
6
- metadata.gz: 26a375d03362845e31c40ea54d9eae12cd1f82d07a904c0f7014468bd377c7d78f7b515334569c746d80a39c188d1087cbe1ac9163665508747872d55b59dcd9
7
- data.tar.gz: e0d5ceffb6636e3f5cff49d2b3e3fcf35c971a602e840d041b50914eb8b01699fc9237aaefef91140256a8288ae9a464da17df4477d4647efc5a637dc1dcf4ab
6
+ metadata.gz: 23fba514a9ba9e5de5590bd84b78cf7231284b9a5c880a3be57c9887320e665f03dd6c270e09a52386ea235e78c3fd8ae85dc910a6318146bc9480e0fe37eb16
7
+ data.tar.gz: b1ed662862fdd3f3ae6b5153ab3482d860260e496695cc272fcb5b549b568045443d84ff713309e9564088478180ac8d0ff0c15abd06667333219e8deed85b6c
data/.rvmrc CHANGED
@@ -1 +1 @@
1
- rvm use 1.9.2@gems
1
+ rvm use 1.9.3@gems
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- role_authorization (0.1.5)
4
+ role_authorization (0.6.0)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -4,6 +4,8 @@ module RoleAuthorization
4
4
  base.class_eval do
5
5
  helper_method :authorized?
6
6
  helper_method :accessible?
7
+
8
+ before_filter :check_request_authorization
7
9
  end
8
10
  base.send :extend, RoleAuthorization::Ruleset::ClassMethods
9
11
  base.send :cattr_ruleset, :ruleset, :allowable_groups
@@ -15,18 +17,10 @@ module RoleAuthorization
15
17
  module ClassMethods
16
18
  def allow_group(*args)
17
19
  add_to_allowable_groups(self.controller_rule_name, args)
18
- add_role_authorization_filter
19
20
  end
20
21
 
21
22
  def allow(options = {}, &block)
22
23
  add_to_ruleset(self.controller_rule_name, &block)
23
- add_role_authorization_filter
24
- end
25
-
26
- def add_role_authorization_filter
27
- callbacks = _process_action_callbacks
28
- chain = callbacks.select {|cl| cl.klass.to_s.include?(name)}.collect(&:filter).select {|c| c.is_a?(Symbol)}
29
- before_filter :check_request_authorization unless chain.include?(:check_request_authorization)
30
24
  end
31
25
 
32
26
  def controller_rule_name
@@ -19,6 +19,11 @@ module RoleAuthorization
19
19
  end
20
20
 
21
21
  module InstanceMethods
22
+ def role(role_name)
23
+ @_role ||= {}
24
+ @_role[role_name] ||= klass.find_by_name(role_name)
25
+ end
26
+
22
27
  def setup(klass)
23
28
  @klass = klass
24
29
  klass.send(:include, RoleAuthorization::Roles::Role)
@@ -20,15 +20,16 @@ module RoleAuthorization
20
20
  end
21
21
 
22
22
  def users(scope = nil)
23
- if user_ids.blank?
24
- []
25
- else
26
- if scope.nil?
27
- RoleAuthorization::Roles::Manager.user_klass.where(:id => user_ids.values.flatten.uniq).all
28
- else
29
- RoleAuthorization::Roles::Manager.user_klass.where(:id => user_ids[scope_with(scope)]).all
30
- end
31
- end
23
+ @users ||= {}
24
+ @users[scope] ||= if user_ids.blank?
25
+ []
26
+ else
27
+ if scope.nil?
28
+ RoleAuthorization::Roles::Manager.user_klass.where(:id => user_ids.values.flatten.uniq).all
29
+ else
30
+ RoleAuthorization::Roles::Manager.user_klass.where(:id => user_ids[scope_with(scope)]).all
31
+ end
32
+ end
32
33
  end
33
34
 
34
35
  def add_user(user_id, scope = nil)
@@ -94,7 +94,7 @@ module RoleAuthorization
94
94
  self.serialized_roles ||= Hash.new
95
95
 
96
96
  (self.serialized_roles[:global] || []).map do |role_name|
97
- RoleAuthorization::Roles.manager.klass.find_by_name(role_name).remove_user(self.id)
97
+ RoleAuthorization::Roles.manager.role(role_name).remove_user(self.id)
98
98
  end
99
99
  self.serialized_roles[:global] = Array.new
100
100
 
@@ -123,7 +123,7 @@ module RoleAuthorization
123
123
  end
124
124
 
125
125
  if save(:validate => false)
126
- RoleAuthorization::Roles.manager.klass.find_by_name(role_name).add_user(self.id, scope)
126
+ RoleAuthorization::Roles.manager.role(role_name).add_user(self.id, scope)
127
127
  true
128
128
  else
129
129
  false
@@ -151,7 +151,7 @@ module RoleAuthorization
151
151
  end
152
152
 
153
153
  if save(:validate => false)
154
- RoleAuthorization::Roles.manager.klass.find_by_name(role_name).remove_user(self.id, scope)
154
+ RoleAuthorization::Roles.manager.role(role_name).remove_user(self.id, scope)
155
155
  true
156
156
  else
157
157
  false
@@ -1,3 +1,3 @@
1
1
  module RoleAuthorization
2
- VERSION = "0.6.2"
2
+ VERSION = "0.9.0"
3
3
  end
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: role_authorization
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John 'asceth' Long
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-16 00:00:00.000000000 Z
11
+ date: 2014-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rr
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  description: A gem for handling authorization in rails using roles
@@ -45,10 +45,10 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
- - .gemtest
49
- - .gitignore
50
- - .rspec
51
- - .rvmrc
48
+ - ".gemtest"
49
+ - ".gitignore"
50
+ - ".rspec"
51
+ - ".rvmrc"
52
52
  - Gemfile
53
53
  - Gemfile.lock
54
54
  - LICENSE
@@ -84,17 +84,17 @@ require_paths:
84
84
  - lib
85
85
  required_ruby_version: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  required_rubygems_version: !ruby/object:Gem::Requirement
91
91
  requirements:
92
- - - '>='
92
+ - - ">="
93
93
  - !ruby/object:Gem::Version
94
94
  version: '0'
95
95
  requirements: []
96
96
  rubyforge_project: role_authorization
97
- rubygems_version: 2.0.3
97
+ rubygems_version: 2.2.2
98
98
  signing_key:
99
99
  specification_version: 4
100
100
  summary: Role Authorization gem for Rails