Skip to content

Commit

Permalink
Merge pull request #444 from samvera-labs/postgres_converter_performance
Browse files Browse the repository at this point in the history
Significantly speed up Postgres ORMConverter.
  • Loading branch information
botimer authored Jun 8, 2018
2 parents 415d511 + f455286 commit e47e620
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions lib/valkyrie/persistence/postgres/orm_converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ def rdf_metadata
class RDFMetadata
attr_reader :metadata
def initialize(metadata)
@metadata = metadata
# nil hash values are handled by the default state in dry-types
# anyways, so don't bother processing them here.
@metadata = metadata.compact
end

def result
Expand Down Expand Up @@ -107,6 +109,20 @@ def result
end
end

# Handles iterating over arrays of values and converting each value.
class EnumeratorValue < ::Valkyrie::ValueMapper
PostgresValue.register(self)
def self.handles?(value)
value.respond_to?(:each)
end

def result
value.map do |value|
calling_mapper.for(value).result
end
end
end

# Converts Date strings to `DateTime`
class DateValue < ::Valkyrie::ValueMapper
PostgresValue.register(self)
Expand All @@ -124,20 +140,6 @@ def result
DateTime.iso8601(value).utc
end
end

# Handles iterating over arrays of values and converting each value.
class EnumeratorValue < ::Valkyrie::ValueMapper
PostgresValue.register(self)
def self.handles?(value)
value.respond_to?(:each)
end

def result
value.map do |value|
calling_mapper.for(value).result
end
end
end
end
end
end

0 comments on commit e47e620

Please sign in to comment.