Skip to content

Added support for YAML serialization/de-serialization of Spira::Base inst#1

Open
gkellogg wants to merge 1 commit intobhuga:masterfrom
ruby-rdf:psych
Open

Added support for YAML serialization/de-serialization of Spira::Base inst#1
gkellogg wants to merge 1 commit intobhuga:masterfrom
ruby-rdf:psych

Conversation

@gkellogg
Copy link

Added support for YAML serialization/de-serialization of Spira::Base instances using Psych.

I basically fixed the serialization I was doing in sparql-tests, and made it more generic. The only other change I found useful was to implement #encode_with and #init_with for RDF::URI, as otherwise Addressable is serialized. This is what I did there. Maybe it should be in Spira too.

# Save short version of URI, without all the Addressable stuff.
class RDF::URI
  def encode_with(coder)
    coder["uri"] = self.to_s
  end

  def init_with(coder)
    @uri = Addressable::URI.parse(coder["uri"])
  end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant