Sha256: 0ae35c85d58181cd50e5ad5098657390ba54286b63ba870e4208a553e9802dc9

Contents?: true

Size: 962 Bytes

Versions: 57

Compression:

Stored size: 962 Bytes

Contents

# frozen_string_literal: true

require "concurrent/map"
require "action_view/path_set"
require "action_view/render_parser"

module ActionView
  class DependencyTracker # :nodoc:
    extend ActiveSupport::Autoload

    autoload :ERBTracker
    autoload :RipperTracker

    @trackers = Concurrent::Map.new

    def self.find_dependencies(name, template, view_paths = nil)
      tracker = @trackers[template.handler]
      return [] unless tracker

      tracker.call(name, template, view_paths)
    end

    def self.register_tracker(extension, tracker)
      handler = Template.handler_for_extension(extension)
      if tracker.respond_to?(:supports_view_paths?)
        @trackers[handler] = tracker
      else
        @trackers[handler] = lambda { |name, template, _|
          tracker.call(name, template)
        }
      end
    end

    def self.remove_tracker(handler)
      @trackers.delete(handler)
    end

    register_tracker :erb, ERBTracker
  end
end

Version data entries

57 entries across 54 versions & 7 rubygems

Version Path
actionview-7.0.4.2 lib/action_view/dependency_tracker.rb
actionview-7.0.4.1 lib/action_view/dependency_tracker.rb
actionview-7.0.4 lib/action_view/dependency_tracker.rb
actionview-7.0.3.1 lib/action_view/dependency_tracker.rb
actionview-7.0.3 lib/action_view/dependency_tracker.rb
actionview-7.0.2.4 lib/action_view/dependency_tracker.rb
actionview-7.0.2.3 lib/action_view/dependency_tracker.rb
actionview-7.0.2.2 lib/action_view/dependency_tracker.rb
actionview-7.0.2.1 lib/action_view/dependency_tracker.rb
actionview-7.0.2 lib/action_view/dependency_tracker.rb
actionview-7.0.1 lib/action_view/dependency_tracker.rb
actionview-7.0.0 lib/action_view/dependency_tracker.rb
actionview-7.0.0.rc3 lib/action_view/dependency_tracker.rb
actionview-7.0.0.rc2 lib/action_view/dependency_tracker.rb
actionview-7.0.0.rc1 lib/action_view/dependency_tracker.rb
actionview-7.0.0.alpha2 lib/action_view/dependency_tracker.rb
actionview-7.0.0.alpha1 lib/action_view/dependency_tracker.rb