Class: ActionController::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/defer_draper/action_controller.rb

Instance Method Summary collapse

Instance Method Details

#defer_draper_decorateObject



23
24
25
# File 'lib/defer_draper/action_controller.rb', line 23

def defer_draper_decorate
    return false
end

#render(options = nil, extra_options = {}, &block) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/defer_draper/action_controller.rb', line 3

def render(options = nil, extra_options = {}, &block)
    if self.defer_draper_decorate
        self.instance_variables.select {|variable|
            not variable.to_s.start_with?('@_')
        }.map {|variable_name|
            [variable_name, self.instance_variable_get(variable_name)]
        }.select {|variable_name, variable|
            variable.respond_to?(:decorate)
        }.each {|variable_name, variable|
            begin
                self.instance_variable_set(variable_name, variable.decorate)
            rescue Draper::UninferrableDecoratorError
                ;
            end
        }
    end

   super(options, extra_options, &block)
end