Class: Otto::RouteHandlers::BaseHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/otto/route_handlers.rb

Overview

Base class for all route handlers Provides common functionality and interface

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(route_definition, otto_instance = nil) ⇒ BaseHandler

Returns a new instance of BaseHandler.



33
34
35
36
# File 'lib/otto/route_handlers.rb', line 33

def initialize(route_definition, otto_instance = nil)
  @route_definition = route_definition
  @otto_instance = otto_instance
end

Instance Attribute Details

#otto_instanceObject (readonly)

Returns the value of attribute otto_instance.



31
32
33
# File 'lib/otto/route_handlers.rb', line 31

def otto_instance
  @otto_instance
end

#route_definitionObject (readonly)

Returns the value of attribute route_definition.



31
32
33
# File 'lib/otto/route_handlers.rb', line 31

def route_definition
  @route_definition
end

Instance Method Details

#call(env, extra_params = {}) ⇒ Array

Execute the route handler

Parameters:

  • env (Hash)

    Rack environment

  • extra_params (Hash) (defaults to: {})

    Additional parameters

Returns:

  • (Array)

    Rack response array

Raises:

  • (NotImplementedError)


42
43
44
# File 'lib/otto/route_handlers.rb', line 42

def call(env, extra_params = {})
  raise NotImplementedError, "Subclasses must implement #call"
end