Module: SDL::Base::ServiceCompendium::VocabularyLoadTransaction
- Includes:
- LoadTransaction
- Included in:
- SDL::Base::ServiceCompendium
- Defined in:
- lib/sdl/base/service_compendium/vocabulary_load_transaction.rb
Overview
A transaction for loading vocabulary definition
Instance Method Summary collapse
-
#load_vocabulary_from_path(path_or_filename) ⇒ Object
Loads vocabulary, either from a file or from a path recursively.
-
#load_vocabulary_from_string(vocabulary_definition, uri) ⇒ Object
Loads a vocabulary from a string.
Methods included from LoadTransaction
Instance Method Details
#load_vocabulary_from_path(path_or_filename) ⇒ Object
Loads vocabulary, either from a file or from a path recursively.
Vocabulary definition files are expected to end with .sdl.rb
11 12 13 14 15 16 17 |
# 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) ⇒ Object
Loads a vocabulary from a string. The URI is used with ServiceCompendium#with_uri.
23 24 25 26 27 28 29 30 31 32 33 |
# 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 |