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
- #+(array) ⇒ Object
- #compact ⇒ Object
- #exists?(path, prefixes, *args) ⇒ Boolean
- #find(*args) ⇒ Object
- #find_all(path, prefixes = [], *args) ⇒ Object
-
#find_all_with_query(query) ⇒ Object
:nodoc:.
- #find_file(path, prefixes = [], *args) ⇒ 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.
16 17 18 |
# File 'lib/action_view/path_set.rb', line 16 def initialize(paths = []) @paths = typecast paths end |
Instance Attribute Details
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
12 13 14 |
# File 'lib/action_view/path_set.rb', line 12 def paths @paths end |
Instance Method Details
#+(array) ⇒ Object
33 34 35 |
# File 'lib/action_view/path_set.rb', line 33 def +(array) PathSet.new(paths + array) end |
#compact ⇒ Object
29 30 31 |
# File 'lib/action_view/path_set.rb', line 29 def compact PathSet.new paths.compact end |
#exists?(path, prefixes, *args) ⇒ Boolean
57 58 59 |
# File 'lib/action_view/path_set.rb', line 57 def exists?(path, prefixes, *args) find_all(path, prefixes, *args).any? end |
#find(*args) ⇒ Object
45 46 47 |
# File 'lib/action_view/path_set.rb', line 45 def find(*args) find_all(*args).first || raise(MissingTemplate.new(self, *args)) end |
#find_all(path, prefixes = [], *args) ⇒ Object
53 54 55 |
# File 'lib/action_view/path_set.rb', line 53 def find_all(path, prefixes = [], *args) _find_all path, prefixes, args, false end |
#find_all_with_query(query) ⇒ Object
:nodoc:
61 62 63 64 65 66 67 68 |
# File 'lib/action_view/path_set.rb', line 61 def find_all_with_query(query) # :nodoc: paths.each do |resolver| templates = resolver.find_all_with_query(query) return templates unless templates.empty? end [] end |
#find_file(path, prefixes = [], *args) ⇒ Object
49 50 51 |
# File 'lib/action_view/path_set.rb', line 49 def find_file(path, prefixes = [], *args) _find_all(path, prefixes, args, true).first || raise(MissingTemplate.new(self, path, prefixes, *args)) end |
#initialize_copy(other) ⇒ Object
20 21 22 23 |
# File 'lib/action_view/path_set.rb', line 20 def initialize_copy(other) @paths = other.paths.dup self end |
#to_ary ⇒ Object
25 26 27 |
# File 'lib/action_view/path_set.rb', line 25 def to_ary paths.dup end |