Sha256: 5a7d0c934daad0a7470826bffcb3a96d280ab0521a0376fb0e508018c7c27181

Contents?: true

Size: 891 Bytes

Versions: 3

Compression:

Stored size: 891 Bytes

Contents

module ForemanTemplates
  class ExportResult
    attr_accessor :exported, :error, :warning

    def initialize(repo, branch, git_user)
      @repo = repo
      @branch = branch
      @git_user = git_user
      @error = nil
      @warning = nil
      @templates = []
      @exported = false
    end

    def add_exported_templates(templates)
      @templates.concat templates
    end

    def to_h
      { :error => @error,
        :warning => @warning,
        :repo => @repo,
        :branch => @branch,
        :git_user => @git_user,
        :templates => dumped_files_result }
    end

    private

    def dumped_files_result
      @templates.map { |template| to_template_h template }
    end

    def to_template_h(template)
      { :id => template.id,
        :name => template.name,
        :exported => @exported,
        :type => template.class.name.underscore }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
foreman_templates-6.0.3 app/services/foreman_templates/export_result.rb
foreman_templates-6.0.2 app/services/foreman_templates/export_result.rb
foreman_templates-6.0.1 app/services/foreman_templates/export_result.rb