class Puppet::Pops::UniqueMergeStrategy

Merges two values that must be either scalar or arrays into a unique set of values.

Scalar values will be converted into a one element arrays and array values will be flattened prior to forming the unique set. The order of the elements is preserved with e1 being the first contributor of elements and e2 the second.

Constants

INSTANCE

Public Class Methods

key() click to toggle source
    # File lib/puppet/pops/merge_strategy.rb
281 def self.key
282   :unique
283 end

Public Instance Methods

checked_merge(e1, e2) click to toggle source

@param e1 [Array<Object>] The first array @param e2 [Array<Object>] The second array @return [Array<Object>] The unique set of elements

    # File lib/puppet/pops/merge_strategy.rb
289 def checked_merge(e1, e2)
290   convert_value(e1) | convert_value(e2)
291 end
convert_value(e) click to toggle source
    # File lib/puppet/pops/merge_strategy.rb
293 def convert_value(e)
294   e.is_a?(Array) ? e.flatten : [e]
295 end
merge_single(value) click to toggle source

If value is an array, then return the result of calling `uniq` on that array. Otherwise, the argument is returned. @param value [Object] the value to merge with nothing @return [Object] the merged value

    # File lib/puppet/pops/merge_strategy.rb
301 def merge_single(value)
302   value.is_a?(Array) ? value.uniq : value
303 end

Protected Instance Methods

value_t() click to toggle source
    # File lib/puppet/pops/merge_strategy.rb
307 def value_t
308   @value_t ||= Types::TypeParser.singleton.parse('Variant[Scalar,Array[Data]]')
309 end