diff options
author | mguetlein <martin.guetlein@gmail.com> | 2011-02-07 10:07:34 +0100 |
---|---|---|
committer | mguetlein <martin.guetlein@gmail.com> | 2011-02-07 10:07:34 +0100 |
commit | 9848197e9e0830c569ae2addcd404c59c0a53180 (patch) | |
tree | 0d6c7cd3adb503e5d3831390dc0de2a9f406e04d /lib/dataset.rb | |
parent | 5ea8356992751af875812f0e244f08760eb30aee (diff) |
add Dataset.exist as find loads all data
Diffstat (limited to 'lib/dataset.rb')
-rw-r--r-- | lib/dataset.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/dataset.rb b/lib/dataset.rb index a4716dc..02b89cb 100644 --- a/lib/dataset.rb +++ b/lib/dataset.rb @@ -56,6 +56,19 @@ module OpenTox dataset.load_all(subjectid) dataset end + + # replaces find as exist check, takes not as long, does NOT raise an un-authorized exception + # @param [String] uri Dataset URI + # @return [Boolean] true if dataset exists and user has get rights, false else + def self.exist?(uri, subjectid=nil) + return false unless uri + dataset = Dataset.new(uri, subjectid) + begin + dataset.load_metadata( subjectid ).size > 0 + rescue + false + end + end # Get all datasets from a service # @param [optional,String] uri URI of the dataset service, defaults to service specified in configuration |