lib/surrounded/access_control.rb in surrounded-0.8.3 vs lib/surrounded/access_control.rb in surrounded-0.8.4
- old
+ new
@@ -14,11 +14,11 @@
define_access_method(name, &block)
end
end
alias_method :guard, :disallow
- def trigger_return_content(name)
+ def trigger_return_content(name, *args, &block)
%{
method_restrictor = "disallow_#{name}?"
if self.respond_to?(method_restrictor, true) && self.send(method_restrictor)
raise ::#{self.to_s}::AccessError.new("access to #{self.name}##{name} is not allowed")
@@ -27,19 +27,22 @@
#{super}
}
end
def define_access_method(name, &block)
- class_eval {
+ mod = Module.new
+ mod.class_eval {
define_method "disallow_#{name}?" do
begin
apply_roles if __apply_role_policy == :trigger
instance_exec(&block)
ensure
remove_roles if __apply_role_policy == :trigger
end
end
}
+ const_set("SurroundedAccess#{name}", mod)
+ include mod
end
module AccessMethods
# Return a Set of all defined triggers regardless of any disallow blocks
def all_triggers
\ No newline at end of file