Class: Cumulus::Common::ListChange

Inherits:
Struct
  • Object
show all
Defined in:
lib/common/models/ListChange.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#addedObject

Returns the value of attribute added

Returns:

  • (Object)

    the current value of added



3
4
5
# File 'lib/common/models/ListChange.rb', line 3

def added
  @added
end

#modifiedObject

Returns the value of attribute modified

Returns:

  • (Object)

    the current value of modified



3
4
5
# File 'lib/common/models/ListChange.rb', line 3

def modified
  @modified
end

#removedObject

Returns the value of attribute removed

Returns:

  • (Object)

    the current value of removed



3
4
5
# File 'lib/common/models/ListChange.rb', line 3

def removed
  @removed
end

Class Method Details

.simple_list_diff(aws, local) ⇒ Object

Public: Creates a ListChange from aws and local arrays with simple types where the ListChange only has added and removed



6
7
8
9
10
11
12
13
# File 'lib/common/models/ListChange.rb', line 6

def self.simple_list_diff(aws, local)
  added = local - aws
  removed = aws - local

  if !added.empty? or !removed.empty?
    ListChange.new(added, removed, nil)
  end
end

Instance Method Details

#empty?Boolean

Public: Returns true if all of added, removed, and modified are either nil or empty

Returns:

  • (Boolean)


16
17
18
# File 'lib/common/models/ListChange.rb', line 16

def empty?
  (self.added.nil? or self.added.empty?) and (self.removed.nil? or self.removed.empty?) and (self.modified.nil? or self.modified.empty?)
end