Class: Valkyrie::Persistence::Solr::ORMConverter::IntegerValue

Inherits:
ValueMapper
  • Object
show all
Defined in:
lib/valkyrie/persistence/solr/orm_converter.rb

Overview

Converts an integer in solr into an Integer

Instance Attribute Summary

Attributes inherited from ValueMapper

#calling_mapper, #value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ValueMapper

for, #initialize, register

Constructor Details

This class inherits a constructor from Valkyrie::ValueMapper

Class Method Details

.handles?(value) ⇒ Boolean

Note:

this determines whether or not this should be mapped to an integer

Determines whether or not a string representation of an Object is prefixed with “integer-”

Parameters:

  • value (Object)

Returns:

  • (Boolean)


415
416
417
# File 'lib/valkyrie/persistence/solr/orm_converter.rb', line 415

def self.handles?(value)
  value.to_s.start_with?("integer-")
end

Instance Method Details

#resultInteger

Parses and casts the Solr field value into the integer value

Returns:

  • (Integer)


421
422
423
# File 'lib/valkyrie/persistence/solr/orm_converter.rb', line 421

def result
  value.sub(/^integer-/, '').to_i
end