Sha256: e6f4dba2f847e6b94a268b89f5796144e3b96868ebbac9f4f5e03e35bbc6a969

Contents?: true

Size: 614 Bytes

Versions: 1

Compression:

Stored size: 614 Bytes

Contents

module SimpleController
  class Router
    class Route
      attr_reader :controller_name, :action_name
      attr_accessor :controller_name_block

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

      def controller(controller_name_block=nil)
        controller_name_block ? controller_name_block.call(controller_name) : "#{controller_name}_controller".classify.constantize
      end

      def call(params, controller_name_block=nil)
        controller(controller_name_block).call action_name, params
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
simple_controller-0.1.1 lib/simple_controller/router/route.rb