Class: ActionView::PathSet
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
|
|
Inherits: | Object |
Defined in: | actionview/lib/action_view/path_set.rb |
Overview
This class is used to store and access paths in Action View. A number of operations are defined so that you can search among the paths in this set and also perform operations on other PathSet
objects.
A LookupContext
will use a PathSet
to store the paths in its context.
Class Method Summary
- .new(paths = []) ⇒ PathSet constructor
Instance Attribute Summary
::Enumerable
- Included
#many? | Returns |
Instance Method Summary
- #+(other)
- #[]
- #compact
- #exists?(path, prefixes, partial, details, details_key, locals) ⇒ Boolean
- #find(path, prefixes, partial, details, details_key, locals)
- #find_all(path, prefixes, partial, details, details_key, locals)
- #include? ⇒ Boolean
- #initialize_copy(other)
- #to_ary
- #search_combinations(prefixes) private
- #typecast(paths) private
::Enumerable
- Included
#compact_blank | Returns a new |
#exclude? | The negative of the |
#excluding | Returns a copy of the enumerable excluding the specified elements. |
#in_order_of | Returns a new |
#including | Returns a new array that includes the passed elements. |
#index_by | Convert an enumerable to a hash, using the block result as the key and the element as the value. |
#index_with | Convert an enumerable to a hash, using the element as the key and the block result as the value. |
#maximum | Calculates the maximum from the extracted elements. |
#minimum | Calculates the minimum from the extracted elements. |
#pick | Extract the given key from the first element in the enumerable. |
#pluck | Extract the given key from each element in the enumerable. |
#sole | Returns the sole item in the enumerable. |
#without | Alias for Enumerable#excluding. |
#as_json |
::ActiveSupport::EnumerableCoreExt::Constants
- Included
Constructor Details
.new(paths = []) ⇒ PathSet
Instance Attribute Details
#each (readonly)
[ GitHub ]#paths (readonly)
[ GitHub ]# File 'actionview/lib/action_view/path_set.rb', line 14
attr_reader :paths
#size (readonly)
[ GitHub ]Instance Method Details
#+(other)
[ GitHub ]#[]
[ GitHub ]#compact
[ GitHub ]
#exists?(path, prefixes, partial, details, details_key, locals) ⇒ Boolean
# File 'actionview/lib/action_view/path_set.rb', line 53
def exists?(path, prefixes, partial, details, details_key, locals) find_all(path, prefixes, partial, details, details_key, locals).any? end
#find(path, prefixes, partial, details, details_key, locals)
[ GitHub ]# File 'actionview/lib/action_view/path_set.rb', line 40
def find(path, prefixes, partial, details, details_key, locals) find_all(path, prefixes, partial, details, details_key, locals).first || raise(MissingTemplate.new(self, path, prefixes, partial, details, details_key, locals)) end
#find_all(path, prefixes, partial, details, details_key, locals)
[ GitHub ]# File 'actionview/lib/action_view/path_set.rb', line 45
def find_all(path, prefixes, partial, details, details_key, locals) search_combinations(prefixes) do |resolver, prefix| templates = resolver.find_all(path, prefix, partial, details, details_key, locals) return templates unless templates.empty? end [] end
#include? ⇒ Boolean
#initialize_copy(other)
[ GitHub ]# File 'actionview/lib/action_view/path_set.rb', line 22
def initialize_copy(other) @paths = other.paths.dup.freeze self end
#search_combinations(prefixes) (private)
[ GitHub ]#to_ary
[ GitHub ]# File 'actionview/lib/action_view/path_set.rb', line 27
def to_ary paths.dup end
#typecast(paths) (private)
[ GitHub ]# File 'actionview/lib/action_view/path_set.rb', line 67
def typecast(paths) paths.map do |path| case path when Pathname, String # This path should only be reached by "direct" users of # ActionView::Base (not using the ViewPaths or Renderer modules). # We can't cache/de-dup the file system resolver in this case as we # don't know which compiled_method_container we'll be rendering to. FileSystemResolver.new(path) when Resolver path else raise TypeError, "#{path.inspect} is not a valid path: must be a String, Pathname, or Resolver" end end end