Sha256: 5365b0581b352e251a563664da1868c56f474bc89d382967bc13264c42fce1ec

Contents?: true

Size: 1.71 KB

Versions: 1

Compression:

Stored size: 1.71 KB

Contents

module ForemanHostExtraValidator
  class Engine < ::Rails::Engine
    engine_name 'foreman_host_extra_validator'

    config.autoload_paths += Dir["#{config.root}/app/models/concerns"]

    initializer 'foreman_host_extra_validator.load_default_settings', :before => :load_config_initializers do |_app|
      require_dependency File.expand_path('../../app/models/setting/foreman_host_extra_validator.rb', __dir__) if begin
                                                                                                                         Setting.table_exists?
                                                                                                                       rescue
                                                                                                                         (false)
                                                                                                                       end
    end

    initializer 'foreman_host_extra_validator.register_plugin', :before => :finisher_hook do |_app|
      Foreman::Plugin.register :foreman_host_extra_validator do
        requires_foreman '>= 1.18'
      end
    end

    config.to_prepare do
      begin
        Host::Managed.send(:include, ForemanHostExtraValidator::HostExtensions)
      rescue => e
        Rails.logger.warn "ForemanHostExtraValidator: skipping engine hook (#{e})\n#{e.backtrace}"
      end
    end

    initializer 'foreman_host_extra_validator.register_gettext', after: :load_config_initializers do |_app|
      locale_dir = File.join(File.expand_path('../..', __dir__), 'locale')
      locale_domain = 'foreman_host_extra_validator'
      Foreman::Gettext::Support.add_text_domain locale_domain, locale_dir
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
foreman_host_extra_validator-0.1.0 lib/foreman_host_extra_validator/engine.rb