Class: Hyde::Handlers::Serve
- Defined in:
- lib/hyde/probe/serve_handler.rb
Overview
Probe that sends files from a location
Instance Attribute Summary collapse
-
#response ⇒ Object
Returns the value of attribute response.
Attributes inherited from Probe
Attributes inherited from Node
Instance Method Summary collapse
-
#initialize(path, parent:) ⇒ Serve
constructor
A new instance of Serve.
-
#process(request) ⇒ Boolean
Method callback on successful request navigation.
Methods inherited from Node
Constructor Details
#initialize(path, parent:) ⇒ Serve
Returns a new instance of Serve.
12 13 14 |
# File 'lib/hyde/probe/serve_handler.rb', line 12 def initialize(path, parent:) super(path, parent: parent) end |
Instance Attribute Details
#response ⇒ Object
Returns the value of attribute response.
16 17 18 |
# File 'lib/hyde/probe/serve_handler.rb', line 16 def response @response end |
Instance Method Details
#process(request) ⇒ Boolean
Method callback on successful request navigation. Tries to serve files matched by handler
22 23 24 25 26 27 28 29 |
# File 'lib/hyde/probe/serve_handler.rb', line 22 def process(request) path = File.(request.filepath) return unless path.start_with? @properties["path"] File.open(path.delete_suffix("/")) rescue StandardError false end |