Class: Valkyrie::Persistence::Postgres::ORMConverter::RDFMetadata::EnumeratorValue
- Inherits:
-
ValueMapper
- Object
- ValueMapper
- Valkyrie::Persistence::Postgres::ORMConverter::RDFMetadata::EnumeratorValue
- Defined in:
- lib/valkyrie/persistence/postgres/orm_converter.rb
Overview
Handles iterating over arrays of values and converting each value.
Instance Attribute Summary
Attributes inherited from ValueMapper
Class Method Summary collapse
-
.handles?(value) ⇒ Boolean
Determines whether or not a value has enumerable behavior.
Instance Method Summary collapse
-
#result ⇒ Array<Object>
Convert the elements in the enumerable value in Valkyrie attribute values Casts single-valued arrays to the first value, letting Types::Set and Types::Array handle converting it back.
Methods inherited from ValueMapper
Constructor Details
This class inherits a constructor from Valkyrie::ValueMapper
Class Method Details
.handles?(value) ⇒ Boolean
Determines whether or not a value has enumerable behavior
190 191 192 |
# File 'lib/valkyrie/persistence/postgres/orm_converter.rb', line 190 def self.handles?(value) value.respond_to?(:each) end |
Instance Method Details
#result ⇒ Array<Object>
Convert the elements in the enumerable value in Valkyrie attribute values Casts single-valued arrays to the first value, letting Types::Set and Types::Array handle converting it back.
198 199 200 201 202 203 204 205 206 |
# File 'lib/valkyrie/persistence/postgres/orm_converter.rb', line 198 def result if value.length == 1 calling_mapper.for(value.first).result else value.map do |value| calling_mapper.for(value).result end end end |