Class: ActionView::PathSet
- Inherits:
-
Object
- Object
- ActionView::PathSet
- Includes:
- Enumerable
- Defined in:
- lib/action_view/path_set.rb
Overview
Action View PathSet
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.
Instance Attribute Summary collapse
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
Instance Method Summary collapse
- #+(other) ⇒ Object
- #compact ⇒ Object
- #exists?(path, prefixes, partial, details, details_key, locals) ⇒ Boolean
- #find(path, prefixes, partial, details, details_key, locals) ⇒ Object
- #find_all(path, prefixes, partial, details, details_key, locals) ⇒ Object
-
#initialize(paths = []) ⇒ PathSet
constructor
A new instance of PathSet.
- #initialize_copy(other) ⇒ Object
- #to_ary ⇒ Object
Constructor Details
#initialize(paths = []) ⇒ PathSet
Returns a new instance of PathSet.
18 19 20 |
# File 'lib/action_view/path_set.rb', line 18 def initialize(paths = []) @paths = typecast(paths).freeze end |
Instance Attribute Details
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
14 15 16 |
# File 'lib/action_view/path_set.rb', line 14 def paths @paths end |
Instance Method Details
#+(other) ⇒ Object
35 36 37 38 |
# File 'lib/action_view/path_set.rb', line 35 def +(other) array = Array === other ? other : other.paths PathSet.new(paths + array) end |
#compact ⇒ Object
31 32 33 |
# File 'lib/action_view/path_set.rb', line 31 def compact PathSet.new paths.compact end |
#exists?(path, prefixes, partial, details, details_key, locals) ⇒ Boolean
53 54 55 |
# File '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) ⇒ Object
40 41 42 43 |
# File '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) ⇒ Object
45 46 47 48 49 50 51 |
# File '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 |
#initialize_copy(other) ⇒ Object
22 23 24 25 |
# File 'lib/action_view/path_set.rb', line 22 def initialize_copy(other) @paths = other.paths.dup.freeze self end |
#to_ary ⇒ Object
27 28 29 |
# File 'lib/action_view/path_set.rb', line 27 def to_ary paths.dup end |