Class: ReactorSDK::Resources::LibraryComparison

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/reactor_sdk/resources/library_comparison.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(current_library_id:, baseline_library_id:, property_id:, current_snapshot:, baseline_snapshot:, entries:) ⇒ LibraryComparison

Returns a new instance of LibraryComparison.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/reactor_sdk/resources/library_comparison.rb', line 15

def initialize(
  current_library_id:,
  baseline_library_id:,
  property_id:,
  current_snapshot:,
  baseline_snapshot:,
  entries:
)
  @current_library_id = current_library_id
  @baseline_library_id = baseline_library_id
  @property_id = property_id
  @current_snapshot = current_snapshot
  @baseline_snapshot = baseline_snapshot
  @entries = Array(entries)
end

Instance Attribute Details

#baseline_library_idObject (readonly)

Returns the value of attribute baseline_library_id.



8
9
10
# File 'lib/reactor_sdk/resources/library_comparison.rb', line 8

def baseline_library_id
  @baseline_library_id
end

#baseline_snapshotObject (readonly)

Returns the value of attribute baseline_snapshot.



8
9
10
# File 'lib/reactor_sdk/resources/library_comparison.rb', line 8

def baseline_snapshot
  @baseline_snapshot
end

#current_library_idObject (readonly)

Returns the value of attribute current_library_id.



8
9
10
# File 'lib/reactor_sdk/resources/library_comparison.rb', line 8

def current_library_id
  @current_library_id
end

#current_snapshotObject (readonly)

Returns the value of attribute current_snapshot.



8
9
10
# File 'lib/reactor_sdk/resources/library_comparison.rb', line 8

def current_snapshot
  @current_snapshot
end

#entriesObject (readonly)

Returns the value of attribute entries.



8
9
10
# File 'lib/reactor_sdk/resources/library_comparison.rb', line 8

def entries
  @entries
end

#property_idObject (readonly)

Returns the value of attribute property_id.



8
9
10
# File 'lib/reactor_sdk/resources/library_comparison.rb', line 8

def property_id
  @property_id
end

Instance Method Details

#added_entriesObject



43
44
45
# File 'lib/reactor_sdk/resources/library_comparison.rb', line 43

def added_entries
  @entries.select(&:added?)
end

#baseline_libraryObject



35
36
37
# File 'lib/reactor_sdk/resources/library_comparison.rb', line 35

def baseline_library
  @baseline_snapshot.library
end

#changed_entriesObject



59
60
61
# File 'lib/reactor_sdk/resources/library_comparison.rb', line 59

def changed_entries
  @entries.reject(&:unchanged?)
end

#changeset_documents(include_unchanged: false) ⇒ Object



63
64
65
66
67
68
69
# File 'lib/reactor_sdk/resources/library_comparison.rb', line 63

def changeset_documents(include_unchanged: false)
  selected_entries = include_unchanged ? @entries : changed_entries

  selected_entries.each_with_index.map do |entry, index|
    entry.changeset_document(position: index)
  end
end

#current_libraryObject



31
32
33
# File 'lib/reactor_sdk/resources/library_comparison.rb', line 31

def current_library
  @current_snapshot.library
end

#eachObject



39
40
41
# File 'lib/reactor_sdk/resources/library_comparison.rb', line 39

def each(&)
  @entries.each(&)
end

#modified_entriesObject



51
52
53
# File 'lib/reactor_sdk/resources/library_comparison.rb', line 51

def modified_entries
  @entries.select(&:modified?)
end

#removed_entriesObject



47
48
49
# File 'lib/reactor_sdk/resources/library_comparison.rb', line 47

def removed_entries
  @entries.select(&:removed?)
end

#unchanged_entriesObject



55
56
57
# File 'lib/reactor_sdk/resources/library_comparison.rb', line 55

def unchanged_entries
  @entries.select(&:unchanged?)
end