Class: Gearbox::Types::Boolean

Inherits:
Object
  • Object
show all
Includes:
Gearbox::Type
Defined in:
lib/gearbox/types/boolean.rb

Overview

A Gearbox::Type for Boolean values. Values will be expressed as booleans and packaged as ‘XSD.boolean` `RDF::Literal`s.

A Resource property can reference this type as ‘Gearbox::Types::Boolean`, `Boolean`, or `XSD.boolean`.

Class Method Summary collapse

Methods included from Gearbox::Type

included

Class Method Details

.serialize(value) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/gearbox/types/boolean.rb', line 20

def self.serialize(value)
  if value
    RDF::Literal.new(true, :datatype => XSD.boolean)
  else 
    RDF::Literal.new(false, :datatype => XSD.boolean)
  end
end

.unserialize(value) ⇒ Object



16
17
18
# File 'lib/gearbox/types/boolean.rb', line 16

def self.unserialize(value)
  value.object == true
end