Class: ActionView::PathSet

Inherits:
Object show all
Includes:
Enumerable
Defined in:
actionpack/lib/action_view/path_set.rb

Overview

Action View PathSet

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Enumerable

#as_json, #each_with_object, #exclude?, #group_by, #index_by, #many?, #sum

Constructor Details

#initialize(paths = []) ⇒ PathSet

Returns a new instance of PathSet.



8
9
10
# File 'actionpack/lib/action_view/path_set.rb', line 8

def initialize(paths = [])
  @paths = typecast paths
end

Instance Attribute Details

#pathsObject (readonly)

Returns the value of attribute paths



6
7
8
# File 'actionpack/lib/action_view/path_set.rb', line 6

def paths
  @paths
end

Instance Method Details

#+(array) ⇒ Object



45
46
47
# File 'actionpack/lib/action_view/path_set.rb', line 45

def +(array)
  PathSet.new(paths + array)
end

#[](i) ⇒ Object



17
18
19
# File 'actionpack/lib/action_view/path_set.rb', line 17

def [](i)
  paths[i]
end

#compactObject



41
42
43
# File 'actionpack/lib/action_view/path_set.rb', line 41

def compact
  PathSet.new paths.compact
end

#each(&block) ⇒ Object



37
38
39
# File 'actionpack/lib/action_view/path_set.rb', line 37

def each(&block)
  paths.each(&block)
end

#exists?(path, prefixes, *args) ⇒ Boolean

Returns:

  • (Boolean)


72
73
74
# File 'actionpack/lib/action_view/path_set.rb', line 72

def exists?(path, prefixes, *args)
  find_all(path, prefixes, *args).any?
end

#find(*args) ⇒ Object



57
58
59
# File 'actionpack/lib/action_view/path_set.rb', line 57

def find(*args)
  find_all(*args).first || raise(MissingTemplate.new(self, *args))
end

#find_all(path, prefixes = [], *args) ⇒ Object



61
62
63
64
65
66
67
68
69
70
# File 'actionpack/lib/action_view/path_set.rb', line 61

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

#include?(item) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'actionpack/lib/action_view/path_set.rb', line 25

def include?(item)
  paths.include? item
end

#initialize_copy(other) ⇒ Object



12
13
14
15
# File 'actionpack/lib/action_view/path_set.rb', line 12

def initialize_copy(other)
  @paths = other.paths.dup
  self
end

#popObject



29
30
31
# File 'actionpack/lib/action_view/path_set.rb', line 29

def pop
  paths.pop
end

#sizeObject



33
34
35
# File 'actionpack/lib/action_view/path_set.rb', line 33

def size
  paths.size
end

#to_aryObject



21
22
23
# File 'actionpack/lib/action_view/path_set.rb', line 21

def to_ary
  paths.dup
end