Class: ActionView::FileSystemResolver

Inherits:
Resolver
  • Object
show all
Defined in:
lib/action_view/template/resolver.rb

Overview

A resolver that loads files from the filesystem.

Direct Known Subclasses

FixtureResolver

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Resolver

#find_all

Constructor Details

#initialize(path) ⇒ FileSystemResolver

Returns a new instance of FileSystemResolver.

Raises:

  • (ArgumentError)


93
94
95
96
97
98
99
# File 'lib/action_view/template/resolver.rb', line 93

def initialize(path)
  raise ArgumentError, "path already is a Resolver class" if path.is_a?(Resolver)
  @unbound_templates = Concurrent::Map.new
  @path_parser = PathParser.new
  @path = File.expand_path(path)
  super()
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



91
92
93
# File 'lib/action_view/template/resolver.rb', line 91

def path
  @path
end

Instance Method Details

#all_template_pathsObject

:nodoc:



117
118
119
120
121
122
123
124
# File 'lib/action_view/template/resolver.rb', line 117

def all_template_paths # :nodoc:
  paths = template_glob("**/*")
  paths.map do |filename|
    filename.from(@path.size + 1).remove(/\.[^\/]*\z/)
  end.uniq.map do |filename|
    TemplatePath.parse(filename)
  end
end

#built_templatesObject

:nodoc:



126
127
128
# File 'lib/action_view/template/resolver.rb', line 126

def built_templates # :nodoc:
  @unbound_templates.values.flatten.flat_map(&:built_templates)
end

#clear_cacheObject



101
102
103
104
105
# File 'lib/action_view/template/resolver.rb', line 101

def clear_cache
  @unbound_templates.clear
  @path_parser = PathParser.new
  super
end

#eql?(resolver) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


112
113
114
# File 'lib/action_view/template/resolver.rb', line 112

def eql?(resolver)
  self.class.equal?(resolver.class) && to_path == resolver.to_path
end

#to_sObject Also known as: to_path



107
108
109
# File 'lib/action_view/template/resolver.rb', line 107

def to_s
  @path.to_s
end