Class: Valkyrie::Persistence::Solr::ORMConverter::EnumerableValue
- Inherits:
-
ValueMapper
- Object
- ValueMapper
- Valkyrie::Persistence::Solr::ORMConverter::EnumerableValue
- Defined in:
- lib/valkyrie/persistence/solr/orm_converter.rb
Overview
Class for handling multiple values in Solr fields
Instance Attribute Summary
Attributes inherited from ValueMapper
Class Method Summary collapse
-
.handles?(value) ⇒ Boolean
Determines whether or not a value behaves like an enumerable value.
Instance Method Summary collapse
-
#result ⇒ String+
Constructs SolrValue objects for each value and returns the String representation For cases where there is only one value, only a single String is returned.
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 behaves like an enumerable value
203 204 205 |
# File 'lib/valkyrie/persistence/solr/orm_converter.rb', line 203 def self.handles?(value) value.respond_to?(:each) end |
Instance Method Details
#result ⇒ String+
Constructs SolrValue objects for each value and returns the String representation For cases where there is only one value, only a single String is returned
210 211 212 213 214 215 216 217 218 |
# File 'lib/valkyrie/persistence/solr/orm_converter.rb', line 210 def result if value.length == 1 calling_mapper.for(value.first).result else value.map do |element| calling_mapper.for(element).result end end end |