Sha256: b8e1c5c2e63380a189f3e537838fd3e37d643b71ffcacd172544ca9551647bcc

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

module Legion
  module Data
    module Models
      class << self
        attr_reader :loaded_models
        def models
          %w[user group extension chain relationship function task runner task_log datacenter environment node setting]
        end

        def load
          Legion::Logging.info 'Loading Legion::Data::Models'
          @loaded_models ||= []
          require_sequel_models(models)
        end

        def require_sequel_models(files = models)
          Dir[File.dirname(__FILE__) + 'models/*.rb'].each { |file| puts file }
          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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
legion-data-0.2.0 lib/legion/data/model.rb