Class: ActionView::Template::Path

Inherits:
Object
  • Object
show all
Defined in:
lib/action_view/template.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Path

Returns a new instance of Path.

Raises:

  • (ArgumentError)


7
8
9
10
# File 'lib/action_view/template.rb', line 7

def initialize(path)
  raise ArgumentError, "path already is a Path class" if path.is_a?(Path)
  @path = (path.ends_with?(File::SEPARATOR) ? path.to(-2) : path).freeze
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



4
5
6
# File 'lib/action_view/template.rb', line 4

def path
  @path
end

#pathsObject (readonly)

Returns the value of attribute paths.



4
5
6
# File 'lib/action_view/template.rb', line 4

def paths
  @paths
end

Class Method Details

.new_and_loaded(path) ⇒ Object



47
48
49
50
51
# File 'lib/action_view/template.rb', line 47

def self.new_and_loaded(path)
  returning new(path) do |path|
    path.load!
  end
end

Instance Method Details

#==(path) ⇒ Object



24
25
26
# File 'lib/action_view/template.rb', line 24

def ==(path)
  to_str == path.to_str
end

#[](path) ⇒ Object

Returns a ActionView::Template object for the given path string. The input path should be relative to the view path directory, hello/index.html.erb. This method also has a special exception to match partial file names without a handler extension. So hello/index.html will match the first template it finds with a known template extension, hello/index.html.erb. Template extensions should not be confused with format extensions html, js, xml, etc. A format must be supplied to match a formated file. hello/index will never match hello/index.html.erb.



41
42
# File 'lib/action_view/template.rb', line 41

def [](path)
end

#eql?(path) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/action_view/template.rb', line 28

def eql?(path)
  to_str == path.to_str
end

#load!Object



44
45
# File 'lib/action_view/template.rb', line 44

def load!
end

#to_sObject



12
13
14
15
16
17
18
# File 'lib/action_view/template.rb', line 12

def to_s
  if defined?(RAILS_ROOT)
    path.to_s.sub(/^#{Regexp.escape(File.expand_path(RAILS_ROOT))}\//, '')
  else
    path.to_s
  end
end

#to_strObject



20
21
22
# File 'lib/action_view/template.rb', line 20

def to_str
  path.to_str
end