Module: Reactive::Mvc::View::RenderablePartial

Extended by:
ActiveSupport::Memoizable
Defined in:
lib/reactive-mvc/view/renderable_partial.rb

Overview

NOTE: The template that this mixin is being included into is frozen so you cannot set or modify any instance variables

Instance Method Summary collapse

Instance Method Details

#counter_nameObject



12
13
14
# File 'lib/reactive-mvc/view/renderable_partial.rb', line 12

def counter_name
  "#{variable_name}_counter".to_sym
end

#render_partial(view, object = nil, local_assigns = {}, as = nil) ⇒ Object

def render(view, local_assigns = {})

  if defined? ActionController
    ActionController::Base.benchmark("Rendered #{path_without_format_and_extension}", Logger::DEBUG, false) do
      super
    end
  else
    super
  end
end


28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/reactive-mvc/view/renderable_partial.rb', line 28

def render_partial(view, object = nil, local_assigns = {}, as = nil)
  object ||= local_assigns[:object] ||
    local_assigns[variable_name]

  if view.respond_to?(:controller)
    ivar = :"@#{variable_name}"
    object ||=
      if view.controller.instance_variable_defined?(ivar)
        ActiveSupport::Deprecation::DeprecatedObjectProxy.new(
          view.controller.instance_variable_get(ivar),
          "#{ivar} will no longer be implicitly assigned to #{variable_name}")
      end
  end

  # Ensure correct object is reassigned to other accessors
  local_assigns[:object] = local_assigns[variable_name] = object
  local_assigns[as] = object if as

  render_template(view, local_assigns)
end

#variable_nameObject



7
8
9
# File 'lib/reactive-mvc/view/renderable_partial.rb', line 7

def variable_name
  name.sub(/\A_/, '').to_sym
end