class ActionView::DependencyTracker::ERBTracker

Constants

EXPLICIT_DEPENDENCY
RENDER_DEPENDENCY

Matches:

render partial: "comments/comment", collection: commentable.comments
render "comments/comments"
render 'comments/comments'
render('comments/comments')

render(@topic)         => render("topics/topic")
render(topics)         => render("topics/topic")
render(message.topics) => render("topics/topic")

Attributes

name[R]
template[R]

Public Class Methods

call(name, template) click to toggle source
# File lib/action_view/dependency_tracker.rb, line 45
def self.call(name, template)
  new(name, template).dependencies
end
new(name, template) click to toggle source
# File lib/action_view/dependency_tracker.rb, line 49
def initialize(name, template)
  @name, @template = name, template
end

Public Instance Methods

dependencies() click to toggle source
# File lib/action_view/dependency_tracker.rb, line 53
def dependencies
  render_dependencies + explicit_dependencies
end

Private Instance Methods

directory() click to toggle source
# File lib/action_view/dependency_tracker.rb, line 66
def directory
  name.split("/")[0..-2].join("/")
end
explicit_dependencies() click to toggle source
# File lib/action_view/dependency_tracker.rb, line 86
def explicit_dependencies
  source.scan(EXPLICIT_DEPENDENCY).flatten.uniq
end
render_dependencies() click to toggle source
# File lib/action_view/dependency_tracker.rb, line 70
def render_dependencies
  source.scan(RENDER_DEPENDENCY).
    collect(&:second).uniq.

    # render(@topic)         => render("topics/topic")
    # render(topics)         => render("topics/topic")
    # render(message.topics) => render("topics/topic")
    collect { |name| name.sub(/\A@?([a-z_]+\.)*([a-z_]+)\z/) { "#{$2.pluralize}/#{$2.singularize}" } }.

    # render("headline") => render("message/headline")
    collect { |name| name.include?("/") ? name : "#{directory}/#{name}" }.

    # replace quotes from string renders
    collect { |name| name.gsub(/["']/, "") }
end
source() click to toggle source
# File lib/action_view/dependency_tracker.rb, line 62
def source
  template.source
end