Module: Hanami::API::DSL::InstanceMethods

Defined in:
lib/hanami/api/dsl.rb

Overview

Since:

  • 0.2.0

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object

Compatibility with Rack protocol

Parameters:

  • env (Hash)

    a Rack env for the current request

Since:

  • 0.2.0



120
121
122
# File 'lib/hanami/api/dsl.rb', line 120

def call(env)
  @app.call(env)
end

#freezeObject

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.

Since:

  • 0.2.0



104
105
106
107
108
109
110
111
112
# File 'lib/hanami/api/dsl.rb', line 104

def freeze
  @app = @router.to_rack_app
  @url_helpers = @router.url_helpers
  @router.remove_instance_variable(:@url_helpers)
  remove_instance_variable(:@router)
  @url_helpers.freeze
  @app.freeze
  super
end

#initialize(router: self.class.router.dup) ⇒ Object

Initialize the app

Parameters:

Since:

  • 0.2.0



96
97
98
99
100
# File 'lib/hanami/api/dsl.rb', line 96

def initialize(router: self.class.router.dup)
  @router = router

  freeze
end

#to_inspectString

Printable routes

Returns:

  • (String)

    printable routes

Since:

  • x.x.x



130
131
132
# File 'lib/hanami/api/dsl.rb', line 130

def to_inspect
  @app.to_inspect
end