Sha256: 55656920a434db5291b1c991207375bcbdf64c4d8a02430f5dac4e4fd8c1ea45
Contents?: true
Size: 1.35 KB
Versions: 3
Compression:
Stored size: 1.35 KB
Contents
# frozen_string_literal: true # typed: true require "active_support/inflections" module Packs module Rails module Integrations class Rails def initialize(app) @app = app Packs::Rails.config.paths.freeze create_engines inject_paths end def create_engines Packs.all.reject(&:is_gem?).each do |pack| next unless pack.metadata['engine'] create_engine(pack) end end def inject_paths Packs.all.reject(&:is_gem?).each do |pack| Packs::Rails.config.paths.each do |path| @app.paths[path] << pack.relative_path.join(path) end end end private def create_namespace(name) namespace = ActiveSupport::Inflector.camelize(name) namespace.split("::").reduce(Object) do |base, mod| if base.const_defined?(mod, false) base.const_get(mod, false) else base.const_set(mod, Module.new) end end end def create_engine(pack) name = pack.last_name namespace = create_namespace(name) stim = Stim.new(pack, namespace) namespace.const_set("Engine", Class.new(::Rails::Engine)).include(stim) end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
packs-rails-0.0.3 | lib/packs/rails/integrations/rails.rb |
packs-rails-0.0.2 | lib/packs/rails/integrations/rails.rb |
packs-rails-0.0.1 | lib/packs/rails/integrations/rails.rb |