Class: PuppetX::SLURM::HashProperty
- Inherits:
-
Puppet::Property
- Object
- Puppet::Property
- PuppetX::SLURM::HashProperty
- Defined in:
- lib/puppet_x/slurm/hash_property.rb
Overview
Class to share among hash properties
Instance Method Summary collapse
- #change_to_s(currentvalue, newvalue) ⇒ Object
- #insync?(is) ⇒ Boolean
-
#is_to_s(currentvalue) ⇒ Object
(also: #should_to_s)
rubocop:disable Style/PredicateName.
Instance Method Details
#change_to_s(currentvalue, newvalue) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/puppet_x/slurm/hash_property.rb', line 23 def change_to_s(currentvalue, newvalue) if currentvalue != :absent && currentvalue.is_a?(Hash) currentvalue = currentvalue.map { |k, v| "#{k}=#{v}" }.join(',') end if newvalue != :absent && newvalue.is_a?(Hash) newvalue = newvalue.map { |k, v| "#{k}=#{v}" }.join(',') end super(currentvalue, newvalue) end |
#insync?(is) ⇒ Boolean
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/puppet_x/slurm/hash_property.rb', line 9 def insync?(is) should = if @should.is_a?(Array) @should[0] else @should end if is.is_a?(Hash) && should.is_a?(Hash) is_sorted = Hash[is.map { |k, v| [k, v.to_s] }].sort_by { |k, _v| k } should_sorted = Hash[should.map { |k, v| [k, v.to_s] }].sort_by { |k, _v| k } return is_sorted == should_sorted end Array(is).sort == Array(should).sort end |
#is_to_s(currentvalue) ⇒ Object Also known as: should_to_s
rubocop:disable Style/PredicateName
33 34 35 36 37 38 |
# File 'lib/puppet_x/slurm/hash_property.rb', line 33 def is_to_s(currentvalue) # rubocop:disable Style/PredicateName if currentvalue != :absent && currentvalue.is_a?(Hash) currentvalue = currentvalue.map { |k, v| "#{k}=#{v}" }.join(',') end currentvalue end |