Class: Valkyrie::Persistence::Postgres::ORMConverter::RDFMetadata

Inherits:
Object
  • Object
show all
Defined in:
lib/valkyrie/persistence/postgres/orm_converter.rb

Overview

Responsible for converting ‘metadata` JSON-B field in Valkyrie::Persistence::Postgres::ORM::Resource into an acceptable hash for Resource

Defined Under Namespace

Classes: DateValue, EnumeratorValue, HashValue, IDValue, NestedRecord, PostgresValue, URIValue

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(metadata) ⇒ RDFMetadata

Returns a new instance of RDFMetadata.

Parameters:

  • metadata (Hash)


86
87
88
89
90
# File 'lib/valkyrie/persistence/postgres/orm_converter.rb', line 86

def initialize()
  # nil hash values are handled by the default state in dry-types
  # anyways, so don't bother processing them here.
  @metadata = .compact
end

Instance Attribute Details

#metadataObject (readonly)

Returns the value of attribute metadata.



83
84
85
# File 'lib/valkyrie/persistence/postgres/orm_converter.rb', line 83

def 
  @metadata
end

Instance Method Details

#resultHash

Convert the database attribute values and map these to the existing keys in the Valkyrie Resource metadata

Returns:

  • (Hash)


94
95
96
97
98
99
100
# File 'lib/valkyrie/persistence/postgres/orm_converter.rb', line 94

def result
  Hash[
    .map do |key, value|
      [key, PostgresValue.for(value).result]
    end
  ]
end