Class: TDiary::Dispatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/tdiary/dispatcher.rb,
lib/tdiary/dispatcher/index_main.rb,
lib/tdiary/dispatcher/update_main.rb

Defined Under Namespace

Classes: IndexMain, UpdateMain

Constant Summary collapse

TARGET =
{
	index: IndexMain,
	update: UpdateMain
}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target) ⇒ Dispatcher



14
15
16
# File 'lib/tdiary/dispatcher.rb', line 14

def initialize( target )
	@target = TARGET[target]
end

Class Method Details

.indexObject



27
28
29
# File 'lib/tdiary/dispatcher.rb', line 27

def index
	new( :index )
end

.updateObject



31
32
33
# File 'lib/tdiary/dispatcher.rb', line 31

def update
	new( :update )
end

Instance Method Details

#call(env) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/tdiary/dispatcher.rb', line 18

def call( env )
	request = adopt_rack_request_to_plain_old_tdiary_style( env )
	main = @target.new( request )
	response = main.run
	apply_security_headers( response, request, main.conf )
	response.to_a
end