Class: Valkyrie::Persistence::Shared::JSONValueMapper::NestedRecord

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

Overview

Converts nested records into Resources

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 multiple keys

Parameters:

  • value (Object)

Returns:

  • (Boolean)


95
96
97
# File 'lib/valkyrie/persistence/shared/json_value_mapper.rb', line 95

def self.handles?(value)
  value.is_a?(Hash) && value.keys.length > 1
end

Instance Method Details

#resultHash

Generates a Hash derived from the JSON for the value

Returns:

  • (Hash)


101
102
103
# File 'lib/valkyrie/persistence/shared/json_value_mapper.rb', line 101

def result
  Valkyrie::Persistence::Shared::JSONValueMapper.new(value).result.symbolize_keys
end