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.
197 198 199 200 201 202 203 204 205 |
# File 'lib/cem_acpt/bolt/cmd/output.rb', line 197 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.
195 196 197 |
# File 'lib/cem_acpt/bolt/cmd/output.rb', line 195 def action @action end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
195 196 197 |
# File 'lib/cem_acpt/bolt/cmd/output.rb', line 195 def object @object end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
195 196 197 |
# File 'lib/cem_acpt/bolt/cmd/output.rb', line 195 def status @status end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
195 196 197 |
# File 'lib/cem_acpt/bolt/cmd/output.rb', line 195 def target @target end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
195 196 197 |
# File 'lib/cem_acpt/bolt/cmd/output.rb', line 195 def value @value end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
239 240 241 242 243 |
# File 'lib/cem_acpt/bolt/cmd/output.rb', line 239 def ==(other) return false unless other.is_a?(self.class) to_h == other.to_h end |
#error ⇒ Object
211 212 213 214 215 |
# File 'lib/cem_acpt/bolt/cmd/output.rb', line 211 def error return unless error? @error ||= new_error end |
#error? ⇒ Boolean
207 208 209 |
# File 'lib/cem_acpt/bolt/cmd/output.rb', line 207 def error? !success? end |
#inspect ⇒ Object
235 236 237 |
# File 'lib/cem_acpt/bolt/cmd/output.rb', line 235 def inspect to_s end |
#output ⇒ Object
221 222 223 224 225 |
# File 'lib/cem_acpt/bolt/cmd/output.rb', line 221 def output return nil if error? value['_output'] || value['output'] || value end |
#success? ⇒ Boolean
217 218 219 |
# File 'lib/cem_acpt/bolt/cmd/output.rb', line 217 def success? status == 'success' end |
#to_h ⇒ Object
227 228 229 |
# File 'lib/cem_acpt/bolt/cmd/output.rb', line 227 def to_h @item_hash end |
#to_s ⇒ Object
231 232 233 |
# File 'lib/cem_acpt/bolt/cmd/output.rb', line 231 def to_s "#<#{self.class}:#{object_id.to_s(16)} #{target},#{action},#{object},#{status}>" end |