lib/ixtlan/guard/guard_rails.rb in ixtlan-guard-0.6.1 vs lib/ixtlan/guard/guard_rails.rb in ixtlan-guard-0.7.0
- old
+ new
@@ -1,13 +1,11 @@
module Ixtlan
module ActionController #:nodoc:
module Guard #:nodoc:
def self.included(base)
base.send(:include, InstanceMethods)
- unless base.respond_to?(:groups_for_current_user)
- base.send(:include, GroupsMethod)
- end
+ base.send(:include, GroupsMethod)
end
module GroupsMethod
protected
@@ -38,12 +36,13 @@
def guard
Rails.application.config.guard
end
def check(flavor = nil, &block)
+ group_method = respond_to?(:current_user_group_names) ? :current_user_group_names : :groups_for_current_user
unless guard.allowed?(params[:controller],
params[:action],
- groups_for_current_user,
+ send(group_method),
flavor,
&block)
if flavor
raise ::Ixtlan::Guard::PermissionDenied.new("permission denied for '#{params[:controller]}##{params[:action]}##{flavor}'")
else