Sha256: f61d64975f5dd3b11fdae621031288856cfeb8c42d7d19f4a4a46ebb29aa2ec5

Contents?: true

Size: 1.51 KB

Versions: 32

Compression:

Stored size: 1.51 KB

Contents

module Plutonium
  module Core
    module Controllers
      module Bootable
        extend ActiveSupport::Concern
        include Plutonium::Engine::Validator

        included do
          helper_method :current_package, :current_engine
        end

        def current_package
          self.class.current_package
        end

        def current_engine
          self.class.current_engine
        end

        class_methods do
          def inherited(subclass)
            super

            # subclass.include Plutonium::Lib::SmartCache
            # subclass.memoize_unless_reloading :current_package
            # subclass.memoize_unless_reloading :current_engine
            subclass.boot
          end

          def boot(package = nil)
            if package.present?
              Plutonium.deprecator.warn(
                "Calling boot with an argument is deprecated and no longer has an effect.",
                caller_locations(1)
              )
            end

            if current_engine != Rails.application.class
              prepend_view_path current_engine.paths["app/views"].first
            end
          end

          def current_package
            (current_engine == Rails.application.class) ? nil : current_engine.module_parent
          end

          def current_engine
            potential_package = module_parents[-2]
            potential_package.nil? ? Rails.application.class : ("#{potential_package}::Engine".safe_constantize || Rails.application.class)
          end
        end
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
plutonium-0.19.2 lib/plutonium/core/controllers/bootable.rb
plutonium-0.19.1 lib/plutonium/core/controllers/bootable.rb
plutonium-0.19.0 lib/plutonium/core/controllers/bootable.rb
plutonium-0.18.8 lib/plutonium/core/controllers/bootable.rb
plutonium-0.18.7 lib/plutonium/core/controllers/bootable.rb
plutonium-0.18.6 lib/plutonium/core/controllers/bootable.rb
plutonium-0.18.5 lib/plutonium/core/controllers/bootable.rb
plutonium-0.18.4 lib/plutonium/core/controllers/bootable.rb
plutonium-0.18.3 lib/plutonium/core/controllers/bootable.rb
plutonium-0.18.2 lib/plutonium/core/controllers/bootable.rb
plutonium-0.18.1 lib/plutonium/core/controllers/bootable.rb
plutonium-0.18.0 lib/plutonium/core/controllers/bootable.rb
plutonium-0.16.5 lib/plutonium/core/controllers/bootable.rb
plutonium-0.16.4 lib/plutonium/core/controllers/bootable.rb
plutonium-0.16.3 lib/plutonium/core/controllers/bootable.rb
plutonium-0.16.1 lib/plutonium/core/controllers/bootable.rb
plutonium-0.16.0 lib/plutonium/core/controllers/bootable.rb
plutonium-0.15.24 lib/plutonium/core/controllers/bootable.rb
plutonium-0.15.23 lib/plutonium/core/controllers/bootable.rb
plutonium-0.15.22 lib/plutonium/core/controllers/bootable.rb