module SDL::Base::ServiceCompendium::VocabularyLoadTransaction
A transaction for loading vocabulary definition
Public Instance Methods
load_vocabulary_from_path(path_or_filename)
click to toggle source
Loads vocabulary, either from a file or from a path recursively.
Vocabulary definition files are expected to end with .sdl.rb
@param path_or_filename Either a filename or a path
# File lib/sdl/base/service_compendium/vocabulary_load_transaction.rb, line 11 def load_vocabulary_from_path(path_or_filename) to_files_array(path_or_filename, '.sdl.rb').each do |filename| with_uri filename do load_vocabulary_from_string File.read(filename), filename end end end
load_vocabulary_from_string(vocabulary_definition, uri)
click to toggle source
Loads a vocabulary from a string. The URI is used with ServiceCompendium#with_uri
. @param [String] vocabulary_definition The vocabulary definition @param [String] uri The URI
# File lib/sdl/base/service_compendium/vocabulary_load_transaction.rb, line 23 def load_vocabulary_from_string(vocabulary_definition, uri) begin with_uri uri do self.instance_eval vocabulary_definition end rescue Exception => e unload uri raise "Error while loading vocabulary from #{uri}: #{e}" end end