Sha256: bda889e15a6b8151507a97e7a1551e6dfc8321d5e1f668ed5b66f07e2207d328

Contents?: true

Size: 1.18 KB

Versions: 4

Compression:

Stored size: 1.18 KB

Contents

require 'fileutils'
require 'yaml'
require 'diffy'
require 'git'

module ForemanTemplates
  # Inherit from the Rails module of the parent app (Foreman), not the plugin.
  # Thus, inhereits from ::Rails::Engine and not from Rails::Engine
  class Engine < ::Rails::Engine
    engine_name 'foreman_templates'

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

    initializer 'foreman_templates.register_plugin', :before => :finisher_hook do
      Foreman::Plugin.register :foreman_templates do
        requires_foreman '>= 1.18'

        apipie_documented_controllers ["#{ForemanTemplates::Engine.root}/app/controllers/api/v2/*.rb"]

        security_block :templates do
          permission :import_templates, {
            :"api/v2/template" => [:import]
          }, :resource_type => 'Template'
          permission :export_templates, {
            :"api/v2/template" => [:export]
          }, :resource_type => 'Template'
        end
        add_all_permissions_to_default_roles
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
foreman_templates-6.0.3 lib/foreman_templates/engine.rb
foreman_templates-6.0.2 lib/foreman_templates/engine.rb
foreman_templates-6.0.1 lib/foreman_templates/engine.rb
foreman_templates-6.0.0 lib/foreman_templates/engine.rb