Class: RDF::Statement
- Inherits:
-
Object
- Object
- RDF::Statement
- Defined in:
- lib/rdf/mongo.rb
Class Method Summary collapse
-
.from_mongo(statement) ⇒ Hash
Create BSON for a statement representation.
Instance Method Summary collapse
-
#to_mongo ⇒ Hash
Creates a BSON representation of the statement.
Class Method Details
.from_mongo(statement) ⇒ Hash
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
22 23 24 25 26 27 28 |
# 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 |
Instance Method Details
#to_mongo ⇒ Hash
Creates a BSON representation of the statement.
10 11 12 13 14 |
# 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 |