lib/grom/node.rb in grom-0.6.1 vs lib/grom/node.rb in grom-1.0.0

- old
+ new

@@ -7,14 +7,14 @@ BLANK = 'blank_node'.freeze attr_reader :statements # @param [Array] statements an array of n-triple statements. - def initialize(statements) + def initialize(statements, decorators = nil) @statements = statements - populate + populate(decorators) end # Allows the user to access instance variables as methods or raise an error if the variable is not defined. # # @param [Symbol] method name of method. @@ -76,11 +76,11 @@ def set_graph_id graph_id = Grom::Helper.get_id(@statements.first.subject) instance_variable_set('@graph_id'.to_sym, graph_id) end - def populate + def populate(decorators) set_graph_id @statements.each do |statement| predicate = Grom::Helper.get_id(statement.predicate).to_sym object = statement.object.to_s @@ -91,9 +91,11 @@ instance_variable << object instance_variable_set("@#{predicate}", instance_variable) else instance_variable_set("@#{predicate}", object) end + + decorators&.decorate_with_type(self, object) if statement.predicate == RDF.type && decorators end end end end