Class: Valkyrie::Persistence::Solr::ModelConverter::SolrRow
- Inherits:
-
Object
- Object
- Valkyrie::Persistence::Solr::ModelConverter::SolrRow
- Defined in:
- lib/valkyrie/persistence/solr/model_converter.rb
Overview
Represents a key/value combination in the solr document, used for isolating logic around how to apply a value to a hash.
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Instance Method Summary collapse
-
#apply_to(hsh) ⇒ Hash
The updated solr hash.
-
#initialize(key:, fields:, values:) ⇒ SolrRow
constructor
A new instance of SolrRow.
Constructor Details
#initialize(key:, fields:, values:) ⇒ SolrRow
Returns a new instance of SolrRow.
163 164 165 166 167 |
# File 'lib/valkyrie/persistence/solr/model_converter.rb', line 163 def initialize(key:, fields:, values:) @key = key @fields = Array.wrap(fields) @values = Array.wrap(values) end |
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
159 160 161 |
# File 'lib/valkyrie/persistence/solr/model_converter.rb', line 159 def fields @fields end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
159 160 161 |
# File 'lib/valkyrie/persistence/solr/model_converter.rb', line 159 def key @key end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
159 160 161 |
# File 'lib/valkyrie/persistence/solr/model_converter.rb', line 159 def values @values end |
Instance Method Details
#apply_to(hsh) ⇒ Hash
Returns The updated solr hash.
171 172 173 174 175 176 177 178 |
# File 'lib/valkyrie/persistence/solr/model_converter.rb', line 171 def apply_to(hsh) return hsh if values.blank? fields.each do |field| hsh["#{key}_#{field}".to_sym] ||= [] hsh["#{key}_#{field}".to_sym] += values end hsh end |