Sha256: 4ea1c631e18f4f6dc87816ed669a9f9501511ffc6869b595cca39ddf6ac45545

Contents?: true

Size: 1.05 KB

Versions: 7

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/core_ext'
require 'eac_rails_base0/paths'
require 'find'
require 'delegate'

module EacRailsBase0
  # A extended version of [Rails::Engine].
  class XEngine < SimpleDelegator
    class << self
      enable_simple_cache

      def require_local
        local_roots.each do |root|
          require_dependency "#{root.basename.to_path.gsub('-', '/')}/engine"
        end
      end

      def local_root
        ::Rails.root.join(::EacRailsBase0::Paths.engines_subpath)
      end

      private

      def all_uncached
        ::Rails::Engine.subclasses.map { |engine_class| new(engine_class.instance) }
      end

      def local_uncached
        all.select(&:local?)
      end

      def local_roots
        local_root.glob('*/*.gemspec').map(&:parent)
      end
    end

    def local?
      return false unless self.class.local_root.directory?

      ::Find.find(self.class.local_root.to_path).include?(config.root.to_path)
    end

    def namespace_module_name
      __getobj__.class.name.deconstantize
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
eac_rails_base0-0.69.0 lib/eac_rails_base0/x_engine.rb
eac_rails_base0-0.68.7 lib/eac_rails_base0/x_engine.rb
eac_rails_base0-0.68.6 lib/eac_rails_base0/x_engine.rb
eac_rails_base0-0.68.5 lib/eac_rails_base0/x_engine.rb
eac_rails_base0-0.68.4 lib/eac_rails_base0/x_engine.rb
eac_rails_base0-0.68.3 lib/eac_rails_base0/x_engine.rb
eac_rails_base0-0.68.2 lib/eac_rails_base0/x_engine.rb