Sha256: aa19d32ec33a7c243c1c9799256ed097e359f5e78f7c8d34ec16c9f17d4dd745

Contents?: true

Size: 629 Bytes

Versions: 1

Compression:

Stored size: 629 Bytes

Contents

module SimpleController
  class Router
    class Route
      attr_reader :controller_path, :action_name

      def initialize(controller_path, action_name)
        @controller_path, @action_name = controller_path, action_name
      end

      def call(params, context, controller_path_block)
        controller_class = controller_path_block ? controller_path_block.call(controller_path) : "#{controller_path}_controller".classify.constantize

        params = { 'controller' => controller_path, 'action' => action_name }.reverse_merge(params)
        controller_class.call action_name, params, context
      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/route.rb