Sha256: ae042f018d4f2f4bbbae43abdaeb00eddc60a3ea62a156d5721e8c7125244e5a

Contents?: true

Size: 989 Bytes

Versions: 14

Compression:

Stored size: 989 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?

        unless route.include?('/')
          route = "#{self.class.container_feature_name}/#{route}"
        end
        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

14 entries across 14 versions & 1 rubygems

Version Path
appfuel-0.7.0 lib/appfuel/handler/action.rb
appfuel-0.6.16 lib/appfuel/handler/action.rb
appfuel-0.6.15 lib/appfuel/handler/action.rb
appfuel-0.6.14 lib/appfuel/handler/action.rb
appfuel-0.6.13 lib/appfuel/handler/action.rb
appfuel-0.6.12 lib/appfuel/handler/action.rb
appfuel-0.6.11 lib/appfuel/handler/action.rb
appfuel-0.6.10 lib/appfuel/handler/action.rb
appfuel-0.6.9 lib/appfuel/handler/action.rb
appfuel-0.6.8 lib/appfuel/handler/action.rb
appfuel-0.6.7 lib/appfuel/handler/action.rb
appfuel-0.6.6 lib/appfuel/handler/action.rb
appfuel-0.6.5 lib/appfuel/handler/action.rb
appfuel-0.6.4 lib/appfuel/handler/action.rb