Class: CemAcpt::Bolt::Cmd::OutputItem
- Inherits:
-
Object
- Object
- CemAcpt::Bolt::Cmd::OutputItem
- Defined in:
- lib/cem_acpt/bolt/cmd/output.rb
Overview
Represents a single item in the output of a Bolt command
Constant Summary collapse
- ATTR_DEFVAL =
'unknown'
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #error ⇒ Object
- #error? ⇒ Boolean
-
#initialize(item_hash, **item_defaults) ⇒ OutputItem
constructor
A new instance of OutputItem.
- #inspect ⇒ Object
- #output ⇒ Object
- #success? ⇒ Boolean
- #to_h ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(item_hash, **item_defaults) ⇒ OutputItem
Returns a new instance of OutputItem.
196 197 198 199 200 201 202 203 204 |
# File 'lib/cem_acpt/bolt/cmd/output.rb', line 196 def initialize(item_hash, **item_defaults) @item_hash = item_hash @item_defaults = item_defaults.transform_keys(&:to_s) @target = item_hash['target'] || @item_defaults['target'] || ATTR_DEFVAL @action = item_hash['action'] || @item_defaults['action'] || ATTR_DEFVAL @object = item_hash['object'] || @item_defaults['object'] || ATTR_DEFVAL @status = item_hash['status'] || 'failure' @value = item_hash['value'] || {} end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
194 195 196 |
# File 'lib/cem_acpt/bolt/cmd/output.rb', line 194 def action @action end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
194 195 196 |
# File 'lib/cem_acpt/bolt/cmd/output.rb', line 194 def object @object end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
194 195 196 |
# File 'lib/cem_acpt/bolt/cmd/output.rb', line 194 def status @status end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
194 195 196 |
# File 'lib/cem_acpt/bolt/cmd/output.rb', line 194 def target @target end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
194 195 196 |
# File 'lib/cem_acpt/bolt/cmd/output.rb', line 194 def value @value end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
238 239 240 241 242 |
# File 'lib/cem_acpt/bolt/cmd/output.rb', line 238 def ==(other) return false unless other.is_a?(self.class) to_h == other.to_h end |
#error ⇒ Object
210 211 212 213 214 |
# File 'lib/cem_acpt/bolt/cmd/output.rb', line 210 def error return unless error? @error ||= new_error end |
#error? ⇒ Boolean
206 207 208 |
# File 'lib/cem_acpt/bolt/cmd/output.rb', line 206 def error? !success? end |
#inspect ⇒ Object
234 235 236 |
# File 'lib/cem_acpt/bolt/cmd/output.rb', line 234 def inspect to_s end |
#output ⇒ Object
220 221 222 223 224 |
# File 'lib/cem_acpt/bolt/cmd/output.rb', line 220 def output return nil if error? value['_output'] || value['output'] || value end |
#success? ⇒ Boolean
216 217 218 |
# File 'lib/cem_acpt/bolt/cmd/output.rb', line 216 def success? status == 'success' end |
#to_h ⇒ Object
226 227 228 |
# File 'lib/cem_acpt/bolt/cmd/output.rb', line 226 def to_h @item_hash end |
#to_s ⇒ Object
230 231 232 |
# File 'lib/cem_acpt/bolt/cmd/output.rb', line 230 def to_s "#<#{self.class}:#{object_id.to_s(16)} #{target},#{action},#{object},#{status}>" end |