Class: Puppet::Property::VDev

Inherits:
Puppet::Property show all
Defined in:
lib/puppet/type/zpool.rb

Overview

VDev class

Direct Known Subclasses

MultiVDev

Instance Method Summary collapse

Instance Method Details

#flatten_and_sort(array) ⇒ Array

Returns a flattened and sorted array

Parameters:

  • array

    the array to be flattened and sorted

Returns:

  • (Array)

    returns a flattened and sorted array



9
10
11
12
# File 'lib/puppet/type/zpool.rb', line 9

def flatten_and_sort(array)
  array = [array] unless array.is_a? Array
  array.map { |a| a.split(' ') }.flatten.sort
end

#insync?(is) ⇒ Boolean

Returns if the resource is in sync with what it should be.

Parameters:

  • is

    the current state of the object

Returns:

  • (Boolean)

    if the resource is in sync with what it should be



16
17
18
19
20
# File 'lib/puppet/type/zpool.rb', line 16

def insync?(is)
  return @should == [:absent] if is == :absent

  flatten_and_sort(is) == flatten_and_sort(@should)
end