Class: Valkyrie::Persistence::Solr::ORMConverter::BooleanValue

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

Overview

Converts an boolean in solr into an Boolean

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 a boolean value

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

Parameters:

  • value (Object)

Returns:

  • (Boolean)


394
395
396
# File 'lib/valkyrie/persistence/solr/orm_converter.rb', line 394

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

Instance Method Details

#resultBoolean

Parses the Solr field value for the substring “true” Should “true” be present, True is returned

Returns:

  • (Boolean)


401
402
403
404
# File 'lib/valkyrie/persistence/solr/orm_converter.rb', line 401

def result
  val = value.sub(/^boolean-/, '')
  val.casecmp("true").zero?
end