Sha256: 41b527971a5e46d06bd28b4548facba7d20fa9affaf6e7cd439ebf6669605b27

Contents?: true

Size: 771 Bytes

Versions: 1

Compression:

Stored size: 771 Bytes

Contents

module ForemanHostRundeck
  module HostsControllerExtensions
    extend ActiveSupport::Concern

    included do
      alias_method_chain :index, :rundeck
      alias_method_chain :show, :rundeck
    end

    def index_with_rundeck
      if params[:format] == 'yaml'
        result = {}
        hosts = resource_base.search_for(params[:search], :order => params[:order]).includes(included_associations)
        hosts.each { |h| result.update(RundeckFormatter.new(h).output) }
        render :text => result.to_yaml
      else
        index_without_rundeck
      end
    end

    def show_with_rundeck
      if params[:format] == 'yaml'
        render :text => RundeckFormatter.new(@host).output.to_yaml
      else
        show_without_rundeck
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
foreman_host_rundeck-0.0.2 app/controllers/concerns/foreman_host_rundeck/hosts_controller_extensions.rb