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
-
#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
60 61 62 |
# File 'lib/action_view/path_set.rb', line 60 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
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/action_view/path_set.rb', line 49 def find_all(path, prefixes = [], *args) prefixes = [prefixes] if String === prefixes prefixes.each do |prefix| paths.each do |resolver| templates = resolver.find_all(path, prefix, *args) return templates unless templates.empty? end end [] 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 |