Class: Simple::Httpd::Mount::PathMount
- Inherits:
-
Object
- Object
- Simple::Httpd::Mount::PathMount
- Defined in:
- lib/simple/httpd/mount.rb
Constant Summary collapse
Instance Attribute Summary collapse
-
#mount_point ⇒ Object
readonly
Returns the value of attribute mount_point.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
- #build_rack_apps ⇒ Object
-
#initialize(mount_point, path) ⇒ PathMount
constructor
A new instance of PathMount.
- #route_descriptions ⇒ Object
Constructor Details
#initialize(mount_point, path) ⇒ PathMount
Returns a new instance of PathMount.
49 50 51 |
# File 'lib/simple/httpd/mount.rb', line 49 def initialize(mount_point, path) @mount_point, @path = mount_point, path end |
Instance Attribute Details
#mount_point ⇒ Object (readonly)
Returns the value of attribute mount_point.
38 39 40 |
# File 'lib/simple/httpd/mount.rb', line 38 def mount_point @mount_point end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
38 39 40 |
# File 'lib/simple/httpd/mount.rb', line 38 def path @path end |
Class Method Details
.build(mount_point, path:) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/simple/httpd/mount.rb', line 40 def self.build(mount_point, path:) path = path.gsub(/\/$/, "") # remove trailing "/" raise ArgumentError, "You probably don't want to mount your root directory, check mount" if path == "" return unless Dir.exist?(path) new(mount_point, path) end |
Instance Method Details
#build_rack_apps ⇒ Object
59 60 61 62 63 64 |
# File 'lib/simple/httpd/mount.rb', line 59 def build_rack_apps dynamic_mount = Rack::DynamicMount.build(mount_point, path) static_mount = Rack::StaticMount.build(mount_point, path) [dynamic_mount, static_mount].compact end |
#route_descriptions ⇒ Object
53 54 55 56 57 |
# File 'lib/simple/httpd/mount.rb', line 53 def route_descriptions build_rack_apps.inject([]) do |ary, app| ary.concat app.route_descriptions end end |