Class: Spira::Types::Any
- Inherits:
-
Object
- Object
- Spira::Types::Any
- Includes:
- Spira::Type
- Defined in:
- lib/spira/types/any.rb
Overview
This class does its best to serialize or unserialize RDF values into Ruby values and vice versa using RDF.rb’s built-in helpers for RDF::Literal
s. Its behavior is defined as ‘What RDF::Literal
does’ for a given value.
Class Method Summary collapse
Class Method Details
.serialize(value) ⇒ Object
18 19 20 21 |
# File 'lib/spira/types/any.rb', line 18 def self.serialize(value) raise TypeError, "Spira::Types::Any cannot serialize collections" if value.is_a?(Array) value.is_a?(RDF::Value) ? value : RDF::Literal.new(value) end |
.unserialize(value) ⇒ Object
14 15 16 |
# File 'lib/spira/types/any.rb', line 14 def self.unserialize(value) value.respond_to?(:object) ? value.object : value end |