Sha256: 66d641241962c8d04082477fa527ccf4b928411e6899bf5613d261c8537ceb5a
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
module Legion module Data class Models attr_reader :loaded_models def initialize(options = {}) options.merge!(default_options) { |_key, v1, _v2| v1 } @loaded_models = [] require_sequel_models if options[:auto_load] end def default_options { continue_on_model_fail: false, auto_load: true } end def models %w[chain relationship function task namespace task_log datacenter environment node] end def require_sequel_models(files = models) files.each { |file| load_sequel_model(file) } end def load_sequel_model(model) Legion::Logging.debug("Trying to load #{model}.rb") require_relative "models/#{model}" @loaded_models << model Legion::Logging.debug("Successfully loaded #{model}") rescue LoadError => e Legion::Logging.fatal("Failed to load #{model}") raise e unless Legion::Settings[:data][:models][:continue_on_fail] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
legion-data-0.1.1 | lib/legion/data/model.rb |