Class: Hyrax::SchemaLoader::AttributeDefinition::Identity Private

Inherits:
Object
  • Object
show all
Defined in:
app/services/hyrax/schema_loader.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Single-value wrapper that matches the multi-value branch's cleanup: strips the dry-types Undefined placeholder and coerces blank strings to nil. Booleans, numbers, and other types pass through unchanged.

Examples:

Identity.of(Valkyrie::Types::String) # => Valkyrie::Types::String with blank-string → nil coercion

Class Method Summary collapse

Class Method Details

.of(type) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



150
151
152
153
154
155
# File 'app/services/hyrax/schema_loader.rb', line 150

def self.of(type)
  type.constructor do |value|
    next nil if value.equal?(Dry::Types::Undefined)
    value.is_a?(String) ? value.presence : value
  end
end