Module: ActionView::Rendering::ClassMethods

Defined in:
actionview/lib/action_view/rendering.rb

Instance Method Summary collapse

Instance Method Details

#_helpersObject


48
49
# File 'actionview/lib/action_view/rendering.rb', line 48

def _helpers
end

#_routesObject


45
46
# File 'actionview/lib/action_view/rendering.rb', line 45

def _routes
end

#build_view_context_class(klass, supports_path, routes, helpers) ⇒ Object


58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'actionview/lib/action_view/rendering.rb', line 58

def build_view_context_class(klass, supports_path, routes, helpers)
  if inherit_view_context_class?
    return superclass.view_context_class
  end

  Class.new(klass) do
    if routes
      include routes.url_helpers(supports_path)
      include routes.mounted_helpers
    end

    if helpers
      include helpers
    end
  end
end

#eager_load!Object


75
76
77
78
79
# File 'actionview/lib/action_view/rendering.rb', line 75

def eager_load!
  super
  view_context_class
  nil
end

#inherit_view_context_class?Boolean

Returns:

  • (Boolean)

51
52
53
54
55
56
# File 'actionview/lib/action_view/rendering.rb', line 51

def inherit_view_context_class?
  superclass.respond_to?(:view_context_class) &&
    supports_path? == superclass.supports_path? &&
    _routes.equal?(superclass._routes) &&
    _helpers.equal?(superclass._helpers)
end

#view_context_classObject


81
82
83
84
85
86
87
88
89
90
91
# File 'actionview/lib/action_view/rendering.rb', line 81

def view_context_class
  klass = ActionView::LookupContext::DetailsKey.view_context_class(ActionView::Base)

  @view_context_class ||= build_view_context_class(klass, supports_path?, _routes, _helpers)

  if klass.changed?(@view_context_class)
    @view_context_class = build_view_context_class(klass, supports_path?, _routes, _helpers)
  end

  @view_context_class
end