Sha256: a3d69098e8c01fc299bdfa7c7467c2806883d705e44f0e94b71b77ebe30bc243

Contents?: true

Size: 729 Bytes

Versions: 46

Compression:

Stored size: 729 Bytes

Contents

# frozen_string_literal: true

module Koi
  module Extensions
    module ObjectRendering
      # Workaround for de-duplicating nested module paths for admin controllers
      # See https://github.com/rails/rails/issues/50916
      def merge_prefix_into_object_path(prefix, object_path)
        if prefix.include?(?/) && object_path.include?(?/)
          prefixes     = []
          prefix_array = File.dirname(prefix).split("/")

          prefix_array.each_with_index do |dir, index|
            break if object_path.start_with?(prefix_array[index..].join("/"))

            prefixes << dir
          end

          (prefixes << object_path).join("/")
        else
          object_path
        end
      end
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
katalyst-koi-4.15.1 lib/koi/extensions/object_rendering.rb
katalyst-koi-4.15.0 lib/koi/extensions/object_rendering.rb
katalyst-koi-4.14.3 lib/koi/extensions/object_rendering.rb
katalyst-koi-4.14.2 lib/koi/extensions/object_rendering.rb
katalyst-koi-4.14.1 lib/koi/extensions/object_rendering.rb
katalyst-koi-4.14.0 lib/koi/extensions/object_rendering.rb
katalyst-koi-4.13.2 lib/koi/extensions/object_rendering.rb
katalyst-koi-4.13.0 lib/koi/extensions/object_rendering.rb
katalyst-koi-4.12.6 lib/koi/extensions/object_rendering.rb
katalyst-koi-4.12.5 lib/koi/extensions/object_rendering.rb
katalyst-koi-4.12.4 lib/koi/extensions/object_rendering.rb
katalyst-koi-4.12.3 lib/koi/extensions/object_rendering.rb
katalyst-koi-4.12.2 lib/koi/extensions/object_rendering.rb
katalyst-koi-4.12.1 lib/koi/extensions/object_rendering.rb
katalyst-koi-4.12.0 lib/koi/extensions/object_rendering.rb
katalyst-koi-4.11.2 lib/koi/extensions/object_rendering.rb
katalyst-koi-4.11.1 lib/koi/extensions/object_rendering.rb
katalyst-koi-4.11.0 lib/koi/extensions/object_rendering.rb
katalyst-koi-4.10.3 lib/koi/extensions/object_rendering.rb
katalyst-koi-4.10.2 lib/koi/extensions/object_rendering.rb