Class: Rails::Paths::Path
- Inherits:
-
Object
- Object
- Rails::Paths::Path
show all
- Includes:
- Enumerable, PathParent
- Defined in:
- lib/rails/paths.rb
Instance Attribute Summary collapse
Attributes included from PathParent
#children
Instance Method Summary
collapse
Methods included from PathParent
#method_missing
Constructor Details
#initialize(root, *paths) ⇒ Path
Returns a new instance of Path.
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/rails/paths.rb', line 86
def initialize(root, *paths)
options = paths.last.is_a?(::Hash) ? paths.pop : {}
@children = {}
@root = root
@paths = paths.flatten
@glob = options[:glob]
autoload_once! if options[:autoload_once]
eager_load! if options[:eager_load]
autoload! if options[:autoload]
load_path! if options[:load_path]
@root.all_paths << self
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Rails::Paths::PathParent
Instance Attribute Details
#glob ⇒ Object
Returns the value of attribute glob.
84
85
86
|
# File 'lib/rails/paths.rb', line 84
def glob
@glob
end
|
#path ⇒ Object
Returns the value of attribute path.
83
84
85
|
# File 'lib/rails/paths.rb', line 83
def path
@path
end
|
Instance Method Details
#concat(paths) ⇒ Object
115
116
117
|
# File 'lib/rails/paths.rb', line 115
def concat(paths)
@paths.concat paths
end
|
#each ⇒ Object
101
102
103
|
# File 'lib/rails/paths.rb', line 101
def each
to_a.each { |p| yield p }
end
|
#paths ⇒ Object
Also known as:
to_a
135
136
137
138
139
140
141
142
143
144
145
146
|
# File 'lib/rails/paths.rb', line 135
def paths
raise "You need to set a path root" unless @root.path
result = @paths.map do |p|
path = File.expand_path(p, @root.path)
@glob ? Dir[File.join(path, @glob)] : path
end
result.flatten!
result.uniq!
result
end
|
#push(path) ⇒ Object
Also known as:
<<
105
106
107
|
# File 'lib/rails/paths.rb', line 105
def push(path)
@paths.push path
end
|
#unshift(path) ⇒ Object
111
112
113
|
# File 'lib/rails/paths.rb', line 111
def unshift(path)
@paths.unshift path
end
|