Class: Ansible::Ruby::Models::Task
- Defined in:
- lib/ansible/ruby/models/task.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#local_action ⇒ Object
:reek:Attribute - This is a simple flag.
Instance Method Summary collapse
Methods inherited from Base
attr_option, attr_options, attribute, fix_inclusion, #initialize, remove_existing_validations, validates
Constructor Details
This class inherits a constructor from Ansible::Ruby::Models::Base
Instance Attribute Details
#local_action ⇒ Object
:reek:Attribute - This is a simple flag
43 44 45 |
# File 'lib/ansible/ruby/models/task.rb', line 43 def local_action @local_action end |
Instance Method Details
#to_h ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/ansible/ruby/models/task.rb', line 51 def to_h result = super # Module gets referenced by name, may not have a module though mod_or_include = @inclusion ? :inclusion : :module flatten = result.delete(mod_or_include) || {} # Module traditionally goes right after name, so rebuilding hash new_result = { name: result.delete(:name) } if @local_action module_name = flatten.keys.first flatten = { local_action: { module: module_name.to_s }.merge(flatten[module_name]) } end new_result.merge! flatten result.each do |key, value| new_result[key] = value end collapse_block = lambda do |which| new_result[which] = new_result[which][:block] if new_result[which] end # If we have a block at this level, get rid of the duplicate {block: block{}}, we'e reusing playbook blocks here collapse_block[:block] collapse_block[:rescue] collapse_block[:always] new_result end |