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.10.1 lib/koi/extensions/object_rendering.rb
katalyst-koi-4.10.0 lib/koi/extensions/object_rendering.rb
katalyst-koi-4.9.5 lib/koi/extensions/object_rendering.rb
katalyst-koi-4.9.4 lib/koi/extensions/object_rendering.rb
katalyst-koi-4.9.3 lib/koi/extensions/object_rendering.rb
katalyst-koi-4.9.2 lib/koi/extensions/object_rendering.rb
katalyst-koi-4.9.1 lib/koi/extensions/object_rendering.rb
katalyst-koi-4.9.0 lib/koi/extensions/object_rendering.rb
katalyst-koi-4.8.1 lib/koi/extensions/object_rendering.rb
katalyst-koi-4.8.0 lib/koi/extensions/object_rendering.rb
katalyst-koi-4.7.3 lib/koi/extensions/object_rendering.rb
katalyst-koi-4.6.0 lib/koi/extensions/object_rendering.rb
katalyst-koi-4.5.9 lib/koi/extensions/object_rendering.rb
katalyst-koi-4.5.8 lib/koi/extensions/object_rendering.rb
katalyst-koi-4.5.7 lib/koi/extensions/object_rendering.rb
katalyst-koi-4.5.6 lib/koi/extensions/object_rendering.rb
katalyst-koi-4.5.5 lib/koi/extensions/object_rendering.rb
katalyst-koi-4.5.4 lib/koi/extensions/object_rendering.rb
katalyst-koi-4.5.3 lib/koi/extensions/object_rendering.rb
katalyst-koi-4.5.2 lib/koi/extensions/object_rendering.rb