Sha256: 8cab83caa36824067c6569c7fd59dc0f73ebffd633a5784ce5b3edc13cec074c

Contents?: true

Size: 650 Bytes

Versions: 6

Compression:

Stored size: 650 Bytes

Contents

module Motorhead
  module Engine
    extend ActiveSupport::Concern

    module ClassMethods
      attr_accessor :on_error, :mount_at

      def active_if(&block)
        @active_if = block
      end

      def active?(controller)
        controller.instance_eval(&@active_if)
      end

      def mount_at(path = nil)
        path ? @mount_at = path : @mount_at
      end
    end

    included do
      isolate_namespace self.parent

      engine_kls = self
      ActiveSupport.on_load :after_initialize do
        Rails.application.routes.prepend do
          mount engine_kls, at: engine_kls.mount_at || '/'
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
motorhead-0.3.5 lib/motorhead/engine.rb
motorhead-0.3.4 lib/motorhead/engine.rb
motorhead-0.3.3 lib/motorhead/engine.rb
motorhead-0.3.2 lib/motorhead/engine.rb
motorhead-0.3.1 lib/motorhead/engine.rb
motorhead-0.3.0 lib/motorhead/engine.rb