lib/surrounded/access_control.rb in surrounded-0.8.1 vs lib/surrounded/access_control.rb in surrounded-0.8.2
- old
+ new
@@ -1,9 +1,12 @@
module Surrounded
module AccessControl
def self.extended(base)
base.send(:include, AccessMethods)
+ unless defined?(base::AccessError)
+ base.const_set(:AccessError, Class.new(::Surrounded::Context::AccessError))
+ end
end
private
def disallow(*names, &block)
@@ -18,13 +21,13 @@
begin
apply_roles if __apply_role_policy == :trigger
method_restrictor = "disallow_#{name}?"
if self.respond_to?(method_restrictor, true) && self.send(method_restrictor)
- raise ::Surrounded::Context::AccessError.new("access to #{self.name}##{name} is not allowed")
+ raise ::#{self.to_s}::AccessError.new("access to #{self.name}##{name} is not allowed")
end
- self.send("__trigger_#{name}")
+ #{trigger_return_content(name)}
ensure
remove_roles if __apply_role_policy == :trigger
end
end
\ No newline at end of file