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
282 def self.key
283   :unique
284 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
290 def checked_merge(e1, e2)
291   convert_value(e1) | convert_value(e2)
292 end
convert_value(e) click to toggle source
    # File lib/puppet/pops/merge_strategy.rb
294 def convert_value(e)
295   e.is_a?(Array) ? e.flatten : [e]
296 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
302 def merge_single(value)
303   value.is_a?(Array) ? value.uniq : value
304 end

Protected Instance Methods

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