Sha256: 5bd46c6c37f314a9e7045e02035c456fc8aa8e57426ebb860fa7f621bfdf1f3b

Contents?: true

Size: 598 Bytes

Versions: 4

Compression:

Stored size: 598 Bytes

Contents

# frozen_string_literal: true

module Hyrax
  ##
  # A custom name for Valkyrie Resource objects. Route keys for resources may
  # not be the same as the model name.
  class ResourceName < Name
    def initialize(klass, namespace = nil, name = nil)
      super
      return unless defined?(Wings::ModelRegistry)

      legacy_model = Wings::ModelRegistry.lookup(klass)
      return unless legacy_model

      @route_key          = legacy_model.model_name.route_key
      @singular_route_key = legacy_model.model_name.singular_route_key
    end

    def human
      super.titleize
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hyrax-5.0.1 lib/hyrax/resource_name.rb
hyrax-5.0.0 lib/hyrax/resource_name.rb
hyrax-5.0.0.rc3 lib/hyrax/resource_name.rb
hyrax-5.0.0.rc2 lib/hyrax/resource_name.rb