Sha256: 2336b46cc01222954f3dadd1feac41e635ca0fea1496f0c916da4af65dcf2739

Contents?: true

Size: 695 Bytes

Versions: 2

Compression:

Stored size: 695 Bytes

Contents

require 'motorhead/errors'

module Motorhead
  module Engine
    extend ActiveSupport::Concern

    module ClassMethods
      attr_accessor :on_error
      attr_reader :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

2 entries across 2 versions & 1 rubygems

Version Path
motorhead-0.3.9 lib/motorhead/engine.rb
motorhead-0.3.8 lib/motorhead/engine.rb