2 # NOTE: The template that this mixin is being included into is frozen
3 # so you cannot set or modify any instance variables
4 module RenderablePartial
#:nodoc:
5 extend ActiveSupport
::Memoizable
8 name
.sub(/\A_/, '').to_sym
10 memoize
:variable_name
13 "#{variable_name}_counter".to_sym
17 def render(view
, local_assigns
= {})
18 if defined? ActionController
19 ActionController
::Base.benchmark("Rendered #{path_without_format_and_extension}", Logger
::DEBUG, false) do
27 def render_partial(view
, object
= nil, local_assigns
= {}, as
= nil)
28 object
||= local_assigns
[:object] || local_assigns
[variable_name
]
30 if object
.nil? && view
.respond_to
?(:controller)
31 ivar
= :"@#{variable_name}"
33 if view
.controller
.instance_variable_defined
?(ivar
)
34 ActiveSupport
::Deprecation::DeprecatedObjectProxy.new(
35 view
.controller
.instance_variable_get(ivar
),
36 "#{ivar} will no longer be implicitly assigned to #{variable_name}")
40 # Ensure correct object is reassigned to other accessors
41 local_assigns
[:object] = local_assigns
[variable_name
] = object
42 local_assigns
[as
] = object
if as
44 render_template(view
, local_assigns
)