Class: QB::Ansible::Module::Response
- Inherits:
-
NRSER::Stash
- Object
- NRSER::Stash
- QB::Ansible::Module::Response
- Includes:
- NRSER::Props::Mutable::Stash
- Defined in:
- lib/qb/ansible/module/response.rb
Overview
Encapsulation of data that an Ansible module responds to Ansible with.
Ansible calls this a module's "return value".
Props collapse
-
#depreciations ⇒ Array<{ msg: String, version: String }>
This key contains a list of dictionaries that will be presented to the user.
-
#warnings ⇒ Array<String>
This key contains a list of strings that will be presented to the user.
Instance Method Summary collapse
-
#convert_key(key) ⇒ Symbol
Uses Symbol keys, and they can not be empty.
-
#initialize(values = {}) ⇒ Response
constructor
Instantiate a new
QB::Ansible::Module::Response
. -
#to_failure(msg:, warnings: [], depreciations: [], **values) ⇒ return_type
Create a new response to represent a failure, copying the stuff that makes sense to keep from this one.
Constructor Details
#initialize(values = {}) ⇒ Response
Instantiate a new QB::Ansible::Module::Response
.
155 156 157 158 |
# File 'lib/qb/ansible/module/response.rb', line 155 def initialize values = {} super() initialize_props values end |
Instance Attribute Details
#depreciations ⇒ Array<{ msg: String, version: String }>
This key contains a list of dictionaries that will be presented to the user. Keys of the dictionaries are msg and version, values are string, value for the version key can be an empty string.
139 140 141 142 143 |
# File 'lib/qb/ansible/module/response.rb', line 139 prop :depreciations, type: t.array( t.shape( msg: t.non_empty_str, version: t.non_empty_str ) ), default: ->{ [] } |
#warnings ⇒ Array<String>
This key contains a list of strings that will be presented to the user.
127 128 129 |
# File 'lib/qb/ansible/module/response.rb', line 127 prop :warnings, type: t.array( t.non_empty_str ), default: -> { [] } |
Instance Method Details
#convert_key(key) ⇒ Symbol
Uses Symbol keys, and they can not be empty. Will convert non-empty strings to their symbols.
170 171 172 173 174 |
# File 'lib/qb/ansible/module/response.rb', line 170 def convert_key key t.match key, t.non_empty_str, :to_sym.to_proc, t.non_empty_sym, key end |
#to_failure(msg:, warnings: [], depreciations: [], **values) ⇒ return_type
Create a new response to represent a failure, copying the stuff that makes sense to keep from this one.
186 187 188 189 190 191 192 |
# File 'lib/qb/ansible/module/response.rb', line 186 def to_failure msg:, warnings: [], depreciations: [], **values self.class.new \ failed: true, msg: msg, warnings: (self.warnings + warnings), depreciations: (self.depreciations + depreciations) end |