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

Initialize and load a new instance of the application

Since:

  • 0.1.0


162
163
164
165
# File 'lib/hanami/application.rb', line 162

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
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/hanami/application.rb', line 28

def self.inherited(base)
  super

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

      # 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.

See Also:

Since:

  • 0.1.0


179
180
181
# File 'lib/hanami/application.rb', line 179

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