Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

support for specifing multiple controllers in single execution of 'al…

…low' method
  • Loading branch information...
commit d79078f5aa8b30dbcfb69aff2e71b10bf7a0383d 1 parent 15cc9d6
@grzegorzkazulak authored
Showing with 18 additions and 2 deletions.
  1. +16 −2 lib/polar/permissions.rb
  2. +2 −0  spec/spec_helper.rb
View
18 lib/polar/permissions.rb
@@ -82,11 +82,11 @@ def initialize(method)
end
def allow(*params)
- add(:allow, params)
+ dispatch(:allow, params)
end
def deny(*params)
- add(:deny, params)
+ dispatch(:deny, params)
end
def add(perm_type, params)
@@ -97,5 +97,19 @@ def add(perm_type, params)
Polar::Permissions.defined_store[self[:permission_name]] ||= []
Polar::Permissions.defined_store[self[:permission_name]] << self
end
+
+ private
+
+ def dispatch(access_type, params)
+ perm_objects = params.first
+ if perm_objects.is_a?(Array)
+ perm_objects.each do |po|
+ params[0] = po
+ add(access_type, params)
+ end
+ else
+ add(access_type, params)
+ end
+ end
end
end
View
2  spec/spec_helper.rb
@@ -53,6 +53,8 @@
Polar.define :permissions do |gp|
gp.edit_profile do |c|
c.allow :users_controller, :only => [:edit, :update]
+ c.allow [:groups_controller, :clients_controller]
+ c.allow [:articles_controller, :contacts_controller], :only => [:index]
end
gp.add_addresses do |c|
Please sign in to comment.
Something went wrong with that request. Please try again.