Sha256: 3fa110888d1918a8ae92f56d8a5cf245b08c86f268feb34884a7e6c74fde8f6a

Contents?: true

Size: 1.68 KB

Versions: 2

Compression:

Stored size: 1.68 KB

Contents

module Raisin

  #
  # Abstract class for all actions.
  #
  class Base < ActionController::Metal
    abstract!

    module Compatibility
      def cache_store; end
      def cache_store=(*); end
      def assets_dir=(*); end
      def javascripts_dir=(*); end
      def stylesheets_dir=(*); end
      def page_cache_directory=(*); end
      def asset_path=(*); end
      def asset_host=(*); end
      def relative_url_root=(*); end
      def perform_caching=(*); end
      def helpers_path=(*); end
      def allow_forgery_protection=(*); end
    end

    extend Compatibility

    MODULES = [
      AbstractController::Helpers,
      ActionController::UrlFor,
      ActionController::Rendering,
      ActionController::Renderers::All,

      ActionController::ConditionalGet,

      ActionController::RackDelegation,
      ActionController::MimeResponds,
      ActionController::ImplicitRender,
      ActionController::DataStreaming,

      AbstractController::Callbacks,
      ActionController::Rescue,

      ActionController::Instrumentation
    ]

    MODULES.each { |mod|
      include mod
    }

    def self.controller_path
      @controller_path ||= name && name.sub(/\:\:[^\:]+$/, '').sub(/api$/i, '').underscore
    end

    def _prefixes
      @_prefixes ||= begin
        parent_prefixes = self.class.parent_prefixes
        parent_prefixes.compact.unshift(controller_path)#.map! { |pr| pr.split('/').last }
      end
    end

    def action_name
      self.class.name.demodulize.underscore
    end

    #
    # In test env, action is not :call. This is a bit of a hack
    #
    def process(action, *args)
      super(:call, *args)
    end

    ActiveSupport.run_load_hooks(:action_controller, self)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
raisin-0.0.5 lib/raisin/base.rb
raisin-0.0.4 lib/raisin/base.rb