Class: Actions::Katello::Agent::DispatchHistoryPresenter
- Inherits:
-
Object
- Object
- Actions::Katello::Agent::DispatchHistoryPresenter
- Defined in:
- app/lib/actions/katello/agent/dispatch_history_presenter.rb
Instance Method Summary collapse
- #error_messages ⇒ Object
- #humanized_output ⇒ Object
-
#initialize(dispatch_history, action_type) ⇒ DispatchHistoryPresenter
constructor
A new instance of DispatchHistoryPresenter.
Constructor Details
#initialize(dispatch_history, action_type) ⇒ DispatchHistoryPresenter
Returns a new instance of DispatchHistoryPresenter.
5 6 7 8 |
# File 'app/lib/actions/katello/agent/dispatch_history_presenter.rb', line 5 def initialize(dispatch_history, action_type) @result = dispatch_history&.result&.with_indifferent_access @action_type = action_type end |
Instance Method Details
#error_messages ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'app/lib/actions/katello/agent/dispatch_history_presenter.rb', line 25 def = [] @result.each_value do |result| if !result[:succeeded] && result.dig(:details, :message) << result[:details][:message] end end end |
#humanized_output ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/lib/actions/katello/agent/dispatch_history_presenter.rb', line 10 def humanized_output return if @result.empty? result = package_result if result[:message] result[:message] elsif result[:packages].any? packages = result[:packages].map { |package| package[:qname] } packages.sort.join("\n") else humanized_no_package end end |