123456789_123456789_123456789_123456789_123456789_

Class: ActionView::DependencyTracker::WildcardResolver

Do not use. This class is for internal use only.
Relationships & Source Files
Inherits: Object
Defined in: actionview/lib/action_view/dependency_tracker/wildcard_resolver.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(view_paths, dependencies) ⇒ WildcardResolver

[ GitHub ]

  
# File 'actionview/lib/action_view/dependency_tracker/wildcard_resolver.rb', line 6

def initialize(view_paths, dependencies)
  @view_paths = view_paths

  @wildcard_dependencies, @explicit_dependencies =
    dependencies.partition { |dependency| dependency.end_with?("/*") }
end

Instance Attribute Details

#explicit_dependencies (readonly, private)

[ GitHub ]

  
# File 'actionview/lib/action_view/dependency_tracker/wildcard_resolver.rb', line 20

attr_reader :explicit_dependencies, :wildcard_dependencies, :view_paths

#view_paths (readonly, private)

[ GitHub ]

  
# File 'actionview/lib/action_view/dependency_tracker/wildcard_resolver.rb', line 20

attr_reader :explicit_dependencies, :wildcard_dependencies, :view_paths

#wildcard_dependencies (readonly, private)

[ GitHub ]

  
# File 'actionview/lib/action_view/dependency_tracker/wildcard_resolver.rb', line 20

attr_reader :explicit_dependencies, :wildcard_dependencies, :view_paths

Instance Method Details

#resolve

[ GitHub ]

  
# File 'actionview/lib/action_view/dependency_tracker/wildcard_resolver.rb', line 13

def resolve
  return explicit_dependencies.uniq if !view_paths || wildcard_dependencies.empty?

  (explicit_dependencies + resolved_wildcard_dependencies).uniq
end

#resolved_wildcard_dependencies (private)

[ GitHub ]

  
# File 'actionview/lib/action_view/dependency_tracker/wildcard_resolver.rb', line 22

def resolved_wildcard_dependencies
  # Remove trailing "/*"
  prefixes = wildcard_dependencies.map { |query| query[0..-3] }

  view_paths.flat_map(&:all_template_paths).uniq.filter_map { |path|
    path.to_s if prefixes.include?(path.prefix)
  }.sort
end