diff options
author | Christoph Helma <helma@in-silico.ch> | 2012-03-15 13:13:44 +0100 |
---|---|---|
committer | Christoph Helma <helma@in-silico.ch> | 2012-03-15 13:13:44 +0100 |
commit | 585a0185af082bc3999375bfcd78677f4dc25059 (patch) | |
tree | 74d891d3dca895d762598ca1f79ef9ab767b481b /lib/opentox.rb | |
parent | e7f1ecb35d0522890a31b9ba44ebf10b05da80a8 (diff) |
metadata reload fixed
Diffstat (limited to 'lib/opentox.rb')
-rw-r--r-- | lib/opentox.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/opentox.rb b/lib/opentox.rb index 9493362..4338302 100644 --- a/lib/opentox.rb +++ b/lib/opentox.rb @@ -27,8 +27,9 @@ module OpenTox # Get object metadata # @return [Hash] Metadata + # TODO: rename to_hash? or store in object variables def metadata - pull if @rdf.empty? + pull # force update metadata = {} @rdf.query([RDF::URI.new(@uri),nil,nil]).collect do |statement| metadata[statement.predicate] ||= [] @@ -41,9 +42,11 @@ module OpenTox # @param [RDF] Key from RDF Vocabularies # @return [Array] Values for supplied key def [](key) - pull if @rdf.empty? + pull # force update result = @rdf.query([RDF::URI.new(@uri),key,nil]).collect{|statement| statement.object} - result.size == 1 ? result.first : result + return nil if result.empty? + return result.first.to_s if result.size == 1 + return result.collect{|r| r.to_s} end # Save object at service |