Class: ActiveFunction::SuperBase

Inherits:
Object
  • Object
show all
Defined in:
lib/active_function/base.rb

Overview

Abstract base class with request processing logic.

Direct Known Subclasses

Base

Instance Attribute Summary collapse

Instance Method Summary collapse

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_nameObject (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

#requestObject (readonly)

Returns the value of attribute request.



6
7
8
# File 'lib/active_function/base.rb', line 6

def request
  @request
end

#responseObject (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

#dispatchObject

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)