Module: Serveable::Item
- Defined in:
- lib/serveable.rb
Overview
The Item module expects the object extending/class including it to respond to the #url and #content methods, it then defines the #serve method which is used by Site.
Instance Method Summary collapse
-
#contents ⇒ String
The contents of the Item to be served.
-
#serve ⇒ Array
Payload for rack.
-
#url ⇒ String
Full url (including /index.html) to the item.
Instance Method Details
#contents ⇒ String
Returns The contents of the Item to be served.
32 |
# File 'lib/serveable.rb', line 32 def contents; end |
#serve ⇒ Array
Returns Payload for rack. Contains, in order, the status, the headers and the body.
39 40 41 42 |
# File 'lib/serveable.rb', line 39 def serve mime = Rack::Mime.mime_type ::File.extname(url) [200, {"Content-Type" => mime}, [contents]] end |
#url ⇒ String
Returns Full url (including /index.html) to the item.
35 |
# File 'lib/serveable.rb', line 35 def url; end |