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.
164 165 166 167 168 |
# File 'lib/valkyrie/persistence/solr/model_converter.rb', line 164 def initialize(key:, fields:, values:) @key = key @fields = fields @values = values end |
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
160 161 162 |
# File 'lib/valkyrie/persistence/solr/model_converter.rb', line 160 def fields @fields end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
160 161 162 |
# File 'lib/valkyrie/persistence/solr/model_converter.rb', line 160 def key @key end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
160 161 162 |
# File 'lib/valkyrie/persistence/solr/model_converter.rb', line 160 def values @values end |
Instance Method Details
#apply_to(hsh) ⇒ Hash
Returns The updated solr hash.
172 173 174 175 176 177 178 179 |
# File 'lib/valkyrie/persistence/solr/model_converter.rb', line 172 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 |