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

Instance Method Details

#contentsString

Returns The contents of the Item to be served.

Returns:

  • (String)

    The contents of the Item to be served.



32
# File 'lib/serveable.rb', line 32

def contents; end

#serveArray

Returns Payload for rack. Contains, in order, the status, the headers and the body.

Returns:

  • (Array)

    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

#urlString

Returns Full url (including /index.html) to the item.

Returns:

  • (String)

    Full url (including /index.html) to the item.



35
# File 'lib/serveable.rb', line 35

def url; end