Class: ActiveFunction::SuperBase
- Inherits:
-
Object
- Object
- ActiveFunction::SuperBase
- Defined in:
- lib/active_function/base.rb
Overview
Abstract base class with request processing logic.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#action_name ⇒ Object
readonly
Returns the value of attribute action_name.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
-
#dispatch ⇒ Object
Executes specified @action_name instance method and returns Hash’ed response object.
-
#initialize(action_name, request, response) ⇒ SuperBase
constructor
A new instance of SuperBase.
- #process(action) ⇒ Object
Constructor Details
#initialize(action_name, request, response) ⇒ SuperBase
Returns a new instance of SuperBase.
8 9 10 11 12 |
# File 'lib/active_function/base.rb', line 8 def initialize(action_name, request, response) @action_name = action_name @request = request @response = response end |
Instance Attribute Details
#action_name ⇒ Object (readonly)
Returns the value of attribute action_name.
6 7 8 |
# File 'lib/active_function/base.rb', line 6 def action_name @action_name end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
6 7 8 |
# File 'lib/active_function/base.rb', line 6 def request @request end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
6 7 8 |
# File 'lib/active_function/base.rb', line 6 def response @response end |
Instance Method Details
#dispatch ⇒ Object
Executes specified @action_name instance method and returns Hash’ed response object
15 16 17 18 19 20 21 |
# File 'lib/active_function/base.rb', line 15 def dispatch process(action_name) @response.commit! unless performed? @response.to_h end |
#process(action) ⇒ Object
23 |
# File 'lib/active_function/base.rb', line 23 def process(action) = public_send(action) |