Module: SDL::Base::ServiceCompendium::ServiceLoadTransaction

Includes:
LoadTransaction
Included in:
SDL::Base::ServiceCompendium
Defined in:
lib/sdl/base/service_compendium/service_load_transaction.rb

Overview

A transaction for loading vocabulary definition

Instance Method Summary collapse

Methods included from LoadTransaction

#to_files_array

Instance Method Details

#load_service_from_path(path_or_filename, ignore_errors = false) ⇒ Object

Loads a service, either from a file or from a path recursively.

Service definition files are expected to end with .service.rb

Parameters:

  • path_or_filename (String)

    Either a filename or a path

  • ignore_errors (Boolean) (defaults to: false)

    Ignore errors when loading service



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/sdl/base/service_compendium/service_load_transaction.rb', line 12

def load_service_from_path(path_or_filename, ignore_errors = false)
  to_files_array(path_or_filename, '.service.rb').each do |filename|
    service_name = filename.match(%r[.+/(.+).service.rb])[1]

    begin
      load_service_from_string File.read(filename), service_name, filename
    rescue Exception => e
      raise e unless ignore_errors
    end
  end
end