Class: Moon::Application::Rack::Route

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

Overview

Abstraction for a application route

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(application, transponder, route) ⇒ Route

Returns a new instance of Route.



59
60
61
62
# File 'lib/moon/application/rack.rb', line 59

def initialize(application, transponder, route)
  @application, @transponder, @route = application, transponder, route
  @environment = @transponder.environment
end

Instance Attribute Details

#rack_responseObject (readonly)

Returns the value of attribute rack_response.



57
58
59
# File 'lib/moon/application/rack.rb', line 57

def rack_response
  @rack_response
end

#responseObject (readonly)

Returns the value of attribute response.



56
57
58
# File 'lib/moon/application/rack.rb', line 56

def response
  @response
end

Instance Method Details

#actionsObject



72
73
74
75
# File 'lib/moon/application/rack.rb', line 72

def actions
  actions = @route[:actions]
  actions.is_a?(Array) ? actions : [ actions ].compact
end

#defineObject



77
78
79
80
81
82
# File 'lib/moon/application/rack.rb', line 77

def define
  route = self
  @transponder.send http_method, path do
    route.handle session, params
  end
end

#handle(session, params) ⇒ Object



84
85
86
87
88
89
# File 'lib/moon/application/rack.rb', line 84

def handle(session, params)
  build_context session, params
  perform_actions
  build_rack_response
  @rack_response
end

#http_methodObject



64
65
66
# File 'lib/moon/application/rack.rb', line 64

def http_method
  @route[:http_method]
end

#pathObject



68
69
70
# File 'lib/moon/application/rack.rb', line 68

def path
  @route[:path]
end