Class: Valkyrie::Persistence::Fedora::Persister::OrmConverter::GraphToAttributes::BooleanValue

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

Overview

Class for mapping RDF boolean literals into Valkyrie Resource attribute values

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

Determines whether or not a Property statement is an RDF literal typed for boolean values

Parameters:

Returns:

  • (Boolean)


294
295
296
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 294

def self.handles?(value)
  value.statement.object.is_a?(RDF::Literal) && value.statement.object.language.blank? && value.statement.object.datatype == PermissiveSchema.valkyrie_bool
end

Instance Method Details

#resultApplicator

Casts the value of the RDF literal into an Applicator for Boolean values

Returns:



300
301
302
303
# File 'lib/valkyrie/persistence/fedora/persister/orm_converter.rb', line 300

def result
  value.statement.object = value.statement.object.value.casecmp("true").zero?
  calling_mapper.for(Property.new(statement: value.statement, scope: value.scope, adapter: value.adapter)).result
end