Sha256: 671d03757c8c798a162c93ad70884662c203c78d44e5c960e7e99e64f4218c33

Contents?: true

Size: 946 Bytes

Versions: 2

Compression:

Stored size: 946 Bytes

Contents

module Appfuel
  module Handler
    class Action < Base
      class << self
        def container_class_type
          'actions'
        end

        # 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.
        #
        # @return [String]
        def container_relative_key
          "actions.#{super}"
        end
      end

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

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

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

        response.ok
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
appfuel-0.6.3 lib/appfuel/handler/action.rb
appfuel-0.6.1 lib/appfuel/handler/action.rb