Sha256: c536500ab3e2018e54340c09bba65e73355905fa796103fb17e64e9a4abc3be0

Contents?: true

Size: 708 Bytes

Versions: 1

Compression:

Stored size: 708 Bytes

Contents

module SimpleController
  class Base
    module Core
      extend ActiveSupport::Concern

      included do
        attr_reader :params, :action_name, :controller_path, :controller_name
      end

      def call(action_name, params={})
        @params ||= ActiveSupport::HashWithIndifferentAccess.new(params)
        @action_name ||= action_name.to_s
        @controller_path ||= params[:controller]
        @controller_name ||= controller_path.split("/").last if controller_path

        call_action
      end

      protected

      def call_action
        public_send action_name
      end

      module ClassMethods
        def call(*args)
          new.call *args
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
simple_controller-1.0.0 lib/simple_controller/base/core.rb