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] ||
29 local_assigns
[variable_name
]
31 if view
.respond_to
?(:controller)
32 ivar
= :"@#{variable_name}"
34 if view
.controller
.instance_variable_defined
?(ivar
)
35 ActiveSupport
::Deprecation::DeprecatedObjectProxy.new(
36 view
.controller
.instance_variable_get(ivar
),
37 "#{ivar} will no longer be implicitly assigned to #{variable_name}")
41 # Ensure correct object is reassigned to other accessors
42 local_assigns
[:object] = local_assigns
[variable_name
] = object
43 local_assigns
[as
] = object
if as
45 render_template(view
, local_assigns
)