lib/surrounded/context.rb in surrounded-0.8.1 vs lib/surrounded/context.rb in surrounded-0.8.2
- old
+ new
@@ -1,9 +1,10 @@
require 'set'
require 'surrounded/context/role_map'
require 'surrounded/access_control'
require 'surrounded/shortcuts'
+require 'surrounded/east_oriented'
# Some features are only available in versions of Ruby
# where this method is true
unless defined?(module_method_rebinding?)
def module_method_rebinding?
@@ -60,11 +61,14 @@
# Provide the ability to create access control methods for your triggers.
def protect_triggers; self.extend(::Surrounded::AccessControl); end
# Automatically create class methods for each trigger method.
- def shortcut_triggers; self.extend(::Surrounded::Shortcuts); end
+ def shortcut_triggers; self.extend(::Surrounded::Shortcuts); end
+
+ # Automatically return the context object from trigger methods.
+ def east_oriented_triggers; self.extend(::Surrounded::EastOriented); end
def default_role_type
@default_role_type ||= Surrounded::Context.default_role_type
end
@@ -190,16 +194,20 @@
class_eval %{
def #{name}
begin
apply_roles if __apply_role_policy == :trigger
- self.send("__trigger_#{name}")
+ #{trigger_return_content(name)}
ensure
remove_roles if __apply_role_policy == :trigger
end
end
}, __FILE__, __LINE__
+ end
+
+ def trigger_return_content(name)
+ %{self.send("__trigger_#{name}")}
end
# === Utility shortcuts
# Set a named constant and make it private
\ No newline at end of file