Class: Ramaze::Files
- Inherits:
-
Object
- Object
- Ramaze::Files
- Defined in:
- lib/ramaze/files.rb
Overview
Class that makes it possible to easily use multiple public directories in your Ramaze application.
Instance Method Summary (collapse)
-
- (Object) <<(path)
Adds a new path to the list of root directories.
-
- (Object) call(env)
Allows this class to be called as a Rack middleware.
-
- (Files) initialize(*roots)
constructor
Creates a new instance of the class, stores the given root directories and syncs the changes with Rack::Cascade.
-
- (Object) sync
Syncs the class with Rack::Cascade.
Constructor Details
- (Files) initialize(*roots)
Creates a new instance of the class, stores the given root directories and syncs the changes with Rack::Cascade.
19 20 21 22 |
# File 'lib/ramaze/files.rb', line 19 def initialize(*roots) @roots = roots.flatten.map{|root| File.(root.to_s) } sync end |
Instance Method Details
- (Object) <<(path)
Adds a new path to the list of root directories.
42 43 44 45 46 |
# File 'lib/ramaze/files.rb', line 42 def <<(path) @roots << File.(path.to_s) @roots.uniq! sync end |
- (Object) call(env)
Allows this class to be called as a Rack middleware.
31 32 33 |
# File 'lib/ramaze/files.rb', line 31 def call(env) @cascade.call(env) end |
- (Object) sync
Syncs the class with Rack::Cascade.
54 55 56 57 |
# File 'lib/ramaze/files.rb', line 54 def sync file_apps = @roots.map { |root| Rack::File.new(root) } @cascade = Rack::Cascade.new(file_apps) end |