class RDF::Statement
Public Class Methods
from_mongo(statement)
click to toggle source
Create BSON for a statement representation. Note that if the statement has no graph name, a value of `false` will be used to indicate the default context
@param [RDF::Statement] statement @return [Hash] Generated BSON representation of statement.
# File lib/rdf/mongo.rb, line 22 def self.from_mongo(statement) RDF::Statement.new( subject: RDF::Mongo::Conversion.from_mongo(statement['s'], statement['st'], statement['sl']), predicate: RDF::Mongo::Conversion.from_mongo(statement['p'], statement['pt'], statement['pl']), object: RDF::Mongo::Conversion.from_mongo(statement['o'], statement['ot'], statement['ol']), graph_name: RDF::Mongo::Conversion.from_mongo(statement['c'], statement['ct'], statement['cl'])) end
Public Instance Methods
to_mongo()
click to toggle source
Creates a BSON representation of the statement. @return [Hash]
# File lib/rdf/mongo.rb, line 10 def to_mongo self.to_h.inject({}) do |hash, (place_in_statement, entity)| hash.merge(RDF::Mongo::Conversion.to_mongo(entity, place_in_statement)) end end