restful_acl 2.1.2 → 2.1.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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.2
1
+ 2.1.3
@@ -7,7 +7,7 @@ module RestfulAclController
7
7
 
8
8
  module ClassMethods
9
9
 
10
- attr_accessor :object, :parent, :klass, :user
10
+ attr_accessor :restful_object, :restful_parent, :restful_klass, :restful_user
11
11
 
12
12
  def has_permission?
13
13
  return true if administrator?
@@ -17,11 +17,11 @@ module RestfulAclController
17
17
  begin
18
18
  # Let's let the Model decide what is acceptable
19
19
  permission_denied unless case params[:action]
20
- when "index" then @klass.is_indexable_by(@user, @parent)
21
- when "new", "create" then @klass.is_creatable_by(@user, @parent)
22
- when "show" then @object.is_readable_by(@user, @parent)
23
- when "edit", "update" then @object.is_updatable_by(@user, @parent)
24
- when "destroy" then @object.is_deletable_by(@user, @parent)
20
+ when "index" then @restful_klass.is_indexable_by(@restful_user, @restful_parent)
21
+ when "new", "create" then @restful_klass.is_creatable_by(@restful_user, @restful_parent)
22
+ when "show" then @restful_object.is_readable_by(@restful_user, @restful_parent)
23
+ when "edit", "update" then @restful_object.is_updatable_by(@restful_user, @restful_parent)
24
+ when "destroy" then @restful_object.is_deletable_by(@restful_user, @restful_parent)
25
25
  else check_non_restful_route
26
26
  end
27
27
 
@@ -37,45 +37,45 @@ module RestfulAclController
37
37
  private
38
38
 
39
39
  def load_actors(id)
40
- @user = current_user
40
+ @restful_user = current_user
41
41
 
42
42
  # Load the Model based on the controller name
43
- @klass = self.controller_name.classify.demodulize.constantize
43
+ @restful_klass = self.controller_name.classify.demodulize.constantize
44
44
 
45
45
  if id.present?
46
46
  # Load the object and possible parent requested
47
- @object = @klass.find(params[:id])
48
- @parent = @object.get_mom if @klass.has_parent?
47
+ @restful_object = @restful_klass.find(params[:id])
48
+ @restful_parent = @restful_object.get_mom if @restful_klass.has_parent?
49
49
  else
50
50
  # No object was requested, so we need to go to the URI to figure out the parent
51
- @parent = get_mom_from_request_uri(@klass) if @klass.has_parent?
51
+ @restful_parent = get_morestful_frorestful_request_uri(@restful_klass) if @restful_klass.has_parent?
52
52
 
53
- if @klass.is_singleton?
54
- @object = @parent.send(@klass.to_s.tableize.singularize.to_sym)
53
+ if @restful_klass.is_singleton?
54
+ @restful_object = @restful_parent.send(@restful_klass.to_s.tableize.singularize.to_sym)
55
55
  else
56
56
  # No object was requested (index, create actions)
57
- @object = nil
57
+ @restful_object = nil
58
58
  end
59
59
  end
60
60
  end
61
61
 
62
62
  def check_non_restful_route
63
- if @object
64
- @object.is_readable_by(@user, @parent)
65
- elsif @klass
66
- @klass.is_indexable_by(@user, @parent)
63
+ if @restful_object
64
+ @restful_object.is_readable_by(@restful_user, @restful_parent)
65
+ elsif @restful_klass
66
+ @restful_klass.is_indexable_by(@restful_user, @restful_parent)
67
67
  else
68
68
  false # If all else fails, deny access
69
69
  end
70
70
  end
71
71
 
72
- def get_method_from_error(error)
72
+ def get_method_frorestful_error(error)
73
73
  error.message.gsub('`', "'").split("'").at(1)
74
74
  end
75
75
 
76
76
  def raise_error(error)
77
- method = get_method_from_error(error)
78
- message = (is_class_method?(method)) ? "#{@klass}#self.#{method}" : "#{@klass}##{method}"
77
+ method = get_method_frorestful_error(error)
78
+ message = (is_class_method?(method)) ? "#{@restful_klass}#self.#{method}" : "#{@restful_klass}##{method}"
79
79
  raise NoMethodError, "[RESTful_ACL] #{message}(user, parent = nil) seems to be missing?"
80
80
  end
81
81
 
@@ -83,7 +83,7 @@ module RestfulAclController
83
83
  method =~ /[index|creat]able/
84
84
  end
85
85
 
86
- def get_mom_from_request_uri(child_klass)
86
+ def get_morestful_frorestful_request_uri(child_klass)
87
87
  parent_klass = child_klass.mom.to_s
88
88
  bits = request.request_uri.split('/')
89
89
  parent_id = bits.at(bits.index(parent_klass.pluralize) + 1)
@@ -92,11 +92,11 @@ module RestfulAclController
92
92
  end
93
93
 
94
94
  def administrator?
95
- @user.respond_to?("is_admin?") && @user.is_admin?
95
+ @restful_user.respond_to?("is_admin?") && @restful_user.is_admin?
96
96
  end
97
97
 
98
98
  def blame
99
- @user.respond_to?(:login) ? @user.login : @user.username
99
+ @restful_user.respond_to?(:login) ? @restful_user.login : @restful_user.username
100
100
  end
101
101
 
102
102
  def permission_denied
File without changes
File without changes
data/lib/restful_acl.rb CHANGED
@@ -1,3 +1,3 @@
1
- require 'controller'
2
- require 'helper'
3
- require 'model'
1
+ require 'restful_acl/controller'
2
+ require 'restful_acl/helper'
3
+ require 'restful_acl/model'
data/restful_acl.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{restful_acl}
8
- s.version = "2.1.2"
8
+ s.version = "2.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Matt Darby"]
@@ -21,10 +21,10 @@ Gem::Specification.new do |s|
21
21
  "Rakefile",
22
22
  "VERSION",
23
23
  "init.rb",
24
- "lib/controller.rb",
25
- "lib/helper.rb",
26
- "lib/model.rb",
27
24
  "lib/restful_acl.rb",
25
+ "lib/restful_acl/controller.rb",
26
+ "lib/restful_acl/helper.rb",
27
+ "lib/restful_acl/model.rb",
28
28
  "rails/init.rb",
29
29
  "restful_acl.gemspec",
30
30
  "uninstall.rb"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restful_acl
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 2.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Darby
@@ -36,10 +36,10 @@ files:
36
36
  - Rakefile
37
37
  - VERSION
38
38
  - init.rb
39
- - lib/controller.rb
40
- - lib/helper.rb
41
- - lib/model.rb
42
39
  - lib/restful_acl.rb
40
+ - lib/restful_acl/controller.rb
41
+ - lib/restful_acl/helper.rb
42
+ - lib/restful_acl/model.rb
43
43
  - rails/init.rb
44
44
  - restful_acl.gemspec
45
45
  - uninstall.rb