Class: Hanami::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/application.rb

Overview

A full stack Hanami application

Examples:

require 'hanami'

module Bookshelf
  class Application < Hanami::Application
  end
end

Since:

  • 0.1.0

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeHanami::Application

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize and load a new instance of the application

Since:

  • 0.1.0



151
152
153
154
# File 'lib/hanami/application.rb', line 151

def initialize
  @renderer   = RenderingPolicy.new(configuration)
  @middleware = configuration.middleware
end

Class Method Details

.inherited(base) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Override Ruby’s Class#inherited



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/hanami/application.rb', line 28

def self.inherited(base)
  super

  base.extend(ClassMethods)
  base.namespace.module_eval do
    class << self
      # Routes for this application
      #
      # @return [Hanami::Routes] the routes for this Hanami application
      #
      # @since 0.9.0
      # @api public
      #
      # @example
      #
      #   Web.routes
      #   Admin.routes
      attr_accessor :routes
    end
  end
end

Instance Method Details

#call(env) ⇒ Array

Process a request. This method makes Hanami applications compatible with the Rack protocol.

Parameters:

  • env (Hash)

    a Rack env

Returns:

  • (Array)

    a serialized Rack response

See Also:

Since:

  • 0.1.0



168
169
170
# File 'lib/hanami/application.rb', line 168

def call(env)
  renderer.render(env, middleware.call(env))
end