Class: SWS::DirectAction

Inherits:
Object
  • Object
show all
Defined in:
lib/sws/direct_action.rb

Overview

DirectAction is a way to define multiple entry point to the application. Default entry point is a default_component defined in application config file. But sometimes you may need more entry points. In such a situation create appropiate …_action methods in your DirectAction class and then you may access them by using application_url/direct_action_key/method_name_without_action_word URL. DirectAction requests are served by instances of this class by default. You can also define your own classes for this purpose.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request) ⇒ DirectAction

Returns a new instance of DirectAction.



19
20
21
# File 'lib/sws/direct_action.rb', line 19

def initialize ( request )
	@request = request
end

Instance Attribute Details

#requestObject (readonly)

The Request object the receiver is associated to



17
18
19
# File 'lib/sws/direct_action.rb', line 17

def request
  @request
end

Instance Method Details

#action_for_name(name) ⇒ Object



31
32
33
34
# File 'lib/sws/direct_action.rb', line 31

def action_for_name ( name )
	# TODO: handle non-existing action?
	return method( name + "_action" ).call()
end

#default_actionObject

This methods returns default_component instance



24
25
26
27
28
29
# File 'lib/sws/direct_action.rb', line 24

def default_action ()

	component = Component.create( Application.instance.default_component_class_name, nil, @request )
	return component.process_request( @request )

end