Sha256: 4680110c3475e7780a582ac40a820ab1d2b3c534f28838f52eb7966cf07a3226

Contents?: true

Size: 878 Bytes

Versions: 2

Compression:

Stored size: 878 Bytes

Contents

# frozen_string_literal: true

# Provide plain collection model if not defined by the application.
# Needed until Hyrax internals do not assume its existence.
class ::Collection < Hyrax.config.collection_class; end unless ActiveSupport::Dependencies.then do |deps|
  # In autoloading environments, when referencing +::Collection+ from the
  # initializer, make sure that +safe_constantize+ wouldn’t just try loading
  # this file again (which would produce a runtime error). Do this by manually
  # searching for the file which should define +::Collection+ and checking if it
  # is the one being currently loaded.
  break true if Object.const_defined?(:Collection)
  file_path = deps.search_for_file("collection")
  expanded = File.expand_path(file_path)
  expanded.delete_suffix!(".rb")
  break false if deps.loading.include?(expanded)
  '::Collection'.safe_constantize
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hyrax-5.0.2 app/models/collection.rb
hyrax-5.0.1 app/models/collection.rb