Class: Valkyrie::Persistence::Shared::JSONValueMapper::IDValue

Inherits:
ValueMapper
  • Object
show all
Defined in:
lib/valkyrie/persistence/shared/json_value_mapper.rb

Overview

Converts stored IDs into IDs

Instance Attribute Summary

Attributes inherited from ValueMapper

#calling_mapper, #value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ValueMapper

for, #initialize, register

Constructor Details

This class inherits a constructor from Valkyrie::ValueMapper

Class Method Details

.handles?(value) ⇒ Boolean

Determines whether or not a value is a Hash containing the key “id” (excluding those storing the Valkyrie Resource type)

Parameters:

  • value (Object)

Returns:

  • (Boolean)


59
60
61
# File 'lib/valkyrie/persistence/shared/json_value_mapper.rb', line 59

def self.handles?(value)
  value.is_a?(Hash) && value["id"] && !value["internal_resource"]
end

Instance Method Details

#resultValkyrie::ID

Constructs a Valkyrie::ID object using the String keyed to “id” in the value

Returns:



65
66
67
# File 'lib/valkyrie/persistence/shared/json_value_mapper.rb', line 65

def result
  Valkyrie::ID.new(value["id"])
end