Class: Appfuel::Handler::Action

Inherits:
Base
  • Object
show all
Defined in:
lib/appfuel/handler/action.rb

Constant Summary

Constants included from InjectDsl

InjectDsl::TYPES

Instance Attribute Summary

Attributes inherited from Base

#data

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#build_criteria, #call, create_handler_failure, create_response, error, #error, fail_handler!, inherited, #initialize, ok, #ok, #present, response?, response_handler, run, run!, #search

Methods included from ValidatorDsl

#default_validator_name, #load_validator, #load_validators, #resolve_inputs, #skip_validation!, #skip_validation?, #validator, #validator_keys, #validators, #validators?

Methods included from InjectDsl

#inject, #injections, #resolve_dependencies

Methods included from Application::AppContainer

#app_container, #feature_name, included, #qualify_container_key

Constructor Details

This class inherits a constructor from Appfuel::Handler::Base

Class Method Details

.container_class_typeObject



5
6
7
# File 'lib/appfuel/handler/action.rb', line 5

def container_class_type
  'actions'
end

.container_relative_keyString

In order to reduce the length of namespaces actions are not required to be inside an Actions namespace, but, it is namespaced with in the application container, so we adjust for that here.

Returns:

  • (String)


14
15
16
# File 'lib/appfuel/handler/action.rb', line 14

def container_relative_key
  "actions.#{super}"
end

Instance Method Details

#dispatch(route, payload = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/appfuel/handler/action.rb', line 19

def dispatch(route, payload = {})
  route = route.to_s
  fail "route can not be empty" if route.empty?

  unless route.include?('/')
    route = "#{self.class.container_feature_name}/#{route}"
  end
  root  = app_container[:root]
  root.call(route, payload)
end

#dispatch!(route, payload = {}) ⇒ Object



30
31
32
33
34
35
# File 'lib/appfuel/handler/action.rb', line 30

def dispatch!(route, payload = {})
  response = dispatch(route, payload)
  fail_handler!(response) if response.failure?

  response.ok
end