Sha256: 1f18989f12109a52f0f012d7ca19ec1867a25743bac84036078f53151f979002

Contents?: true

Size: 766 Bytes

Versions: 1

Compression:

Stored size: 766 Bytes

Contents

module SimpleController
  class Router
    module Context
      extend ActiveSupport::Concern

      included do
        attr_reader :context
      end

      def call(route_path, params={})
        route_path = parse_route_path(route_path.to_s)

        super(route_path, params)
      ensure
        @context = nil
      end

      protected

      def _call(route)
        route.call params, context, controller_path_block
      end

      def parse_route_path(route_path)
        processors = []

        until (extension = File.extname(route_path)).empty?
          route_path = route_path.chomp(extension)
          processors << extension[1..-1].to_sym
        end

        @context = { processors: processors }

        route_path
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
simple_controller-1.0.0 lib/simple_controller/router/context.rb