lib/rdf/model/statement.rb in rdf-0.2.1 vs lib/rdf/model/statement.rb in rdf-0.2.2
- old
+ new
@@ -19,9 +19,21 @@
# })
#
class Statement
include RDF::Value
+ ##
+ # @private
+ # @since 0.2.2
+ def self.from(statement)
+ case statement
+ when Statement then statement
+ when Hash then self.new(statement)
+ when Array then self.new(*statement)
+ else raise ArgumentError.new("expected RDF::Statement, Hash, or Array, but got #{statement.inspect}")
+ end
+ end
+
# @return [Object]
attr_accessor :id
# @return [RDF::Resource]
attr_accessor :context