Commit 92a3d45e427b0693d6fafee1753c5e93a1c24d6b
1 parent
884e842c
Exists in
master
and in
28 other branches
Simplify Noosfero::Plugin::Context
Showing
1 changed file
with
5 additions
and
27 deletions
Show diff stats
lib/noosfero/plugin/context.rb
1 | +# This class defines the interface to important context information from the | |
2 | +# controller that can be accessed by plugins | |
1 | 3 | class Noosfero::Plugin::Context |
2 | 4 | |
3 | 5 | def initialize(controller) |
4 | 6 | @controller = controller |
5 | 7 | end |
6 | 8 | |
7 | - # Here the developer should define the interface to important context | |
8 | - # information from the controller to the plugins to access | |
9 | - def profile | |
10 | - @profile ||= @controller.send(:profile) | |
11 | - end | |
12 | - | |
13 | - def request | |
14 | - @request ||= @controller.send(:request) | |
15 | - end | |
9 | + delegate :profile, :request, :response, :environment, :params, :session, :user, :to => :controller | |
16 | 10 | |
17 | - def response | |
18 | - @response ||= @controller.send(:response) | |
19 | - end | |
20 | - | |
21 | - def environment | |
22 | - @environment ||= @controller.send(:environment) | |
23 | - end | |
11 | + protected | |
24 | 12 | |
25 | - def params | |
26 | - @params ||= @controller.send(:params) | |
27 | - end | |
28 | - | |
29 | - def session | |
30 | - @session ||= @controller.send(:session) | |
31 | - end | |
32 | - | |
33 | - def user | |
34 | - @user ||= @controller.send(:user) | |
35 | - end | |
13 | + attr_reader :controller | |
36 | 14 | |
37 | 15 | end | ... | ... |