Sha256: e781a08f8566b490847da488f07fc2c7d982de4e2be8424b10267728e3e30bbe

Contents?: true

Size: 945 Bytes

Versions: 7

Compression:

Stored size: 945 Bytes

Contents

module ForemanTemplates
  class ExportResult
    attr_accessor :exported, :error, :warning
    attr_reader :templates, :git_user, :branch, :repo

    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

7 entries across 7 versions & 1 rubygems

Version Path
foreman_templates-7.0.6 app/services/foreman_templates/export_result.rb
foreman_templates-7.0.5 app/services/foreman_templates/export_result.rb
foreman_templates-7.0.4 app/services/foreman_templates/export_result.rb
foreman_templates-7.0.3 app/services/foreman_templates/export_result.rb
foreman_templates-7.0.2 app/services/foreman_templates/export_result.rb
foreman_templates-7.0.1 app/services/foreman_templates/export_result.rb
foreman_templates-7.0.0 app/services/foreman_templates/export_result.rb