From 92a3d45e427b0693d6fafee1753c5e93a1c24d6b Mon Sep 17 00:00:00 2001 From: Antonio Terceiro Date: Thu, 8 Mar 2012 22:49:15 -0300 Subject: [PATCH] Simplify Noosfero::Plugin::Context --- lib/noosfero/plugin/context.rb | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/lib/noosfero/plugin/context.rb b/lib/noosfero/plugin/context.rb index 58d464d..1f8f92e 100644 --- a/lib/noosfero/plugin/context.rb +++ b/lib/noosfero/plugin/context.rb @@ -1,37 +1,15 @@ +# This class defines the interface to important context information from the +# controller that can be accessed by plugins class Noosfero::Plugin::Context def initialize(controller) @controller = controller end - # Here the developer should define the interface to important context - # information from the controller to the plugins to access - def profile - @profile ||= @controller.send(:profile) - end - - def request - @request ||= @controller.send(:request) - end + delegate :profile, :request, :response, :environment, :params, :session, :user, :to => :controller - def response - @response ||= @controller.send(:response) - end - - def environment - @environment ||= @controller.send(:environment) - end + protected - def params - @params ||= @controller.send(:params) - end - - def session - @session ||= @controller.send(:session) - end - - def user - @user ||= @controller.send(:user) - end + attr_reader :controller end -- libgit2 0.21.2