Class: ReactorSDK::Resources::LibraryComparisonEntry
- Inherits:
-
Object
- Object
- ReactorSDK::Resources::LibraryComparisonEntry
- Defined in:
- lib/reactor_sdk/resources/library_comparison_entry.rb
Instance Attribute Summary collapse
-
#baseline_comprehensive_resource ⇒ Object
readonly
Returns the value of attribute baseline_comprehensive_resource.
-
#baseline_library_id ⇒ Object
readonly
Returns the value of attribute baseline_library_id.
-
#baseline_resource ⇒ Object
readonly
Returns the value of attribute baseline_resource.
-
#baseline_revision_id ⇒ Object
readonly
Returns the value of attribute baseline_revision_id.
-
#current_comprehensive_resource ⇒ Object
readonly
Returns the value of attribute current_comprehensive_resource.
-
#current_library_id ⇒ Object
readonly
Returns the value of attribute current_library_id.
-
#current_resource ⇒ Object
readonly
Returns the value of attribute current_resource.
-
#current_revision_id ⇒ Object
readonly
Returns the value of attribute current_revision_id.
-
#resource_id ⇒ Object
readonly
Returns the value of attribute resource_id.
-
#resource_type ⇒ Object
readonly
Returns the value of attribute resource_type.
Instance Method Summary collapse
- #added? ⇒ Boolean
- #baseline_normalized_json ⇒ Object
- #baseline_normalized_payload ⇒ Object
- #changed? ⇒ Boolean
- #changeset_document(position: nil) ⇒ Object
- #current_normalized_json ⇒ Object
- #current_normalized_payload ⇒ Object
-
#initialize(resource_id:, resource_type:, current_library_id:, baseline_library_id:, current_resource:, baseline_resource:, current_revision_id:, baseline_revision_id:, current_comprehensive_resource:, baseline_comprehensive_resource:) ⇒ LibraryComparisonEntry
constructor
A new instance of LibraryComparisonEntry.
- #modified? ⇒ Boolean
- #present_in_baseline? ⇒ Boolean
- #present_in_current? ⇒ Boolean
- #removed? ⇒ Boolean
- #resource_name ⇒ Object
- #status ⇒ Object
- #unchanged? ⇒ Boolean
Constructor Details
#initialize(resource_id:, resource_type:, current_library_id:, baseline_library_id:, current_resource:, baseline_resource:, current_revision_id:, baseline_revision_id:, current_comprehensive_resource:, baseline_comprehensive_resource:) ⇒ LibraryComparisonEntry
Returns a new instance of LibraryComparisonEntry.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/reactor_sdk/resources/library_comparison_entry.rb', line 17 def initialize( resource_id:, resource_type:, current_library_id:, baseline_library_id:, current_resource:, baseline_resource:, current_revision_id:, baseline_revision_id:, current_comprehensive_resource:, baseline_comprehensive_resource: ) @resource_id = resource_id @resource_type = resource_type @current_library_id = current_library_id @baseline_library_id = baseline_library_id @current_resource = current_resource @baseline_resource = baseline_resource @current_revision_id = current_revision_id @baseline_revision_id = baseline_revision_id @current_comprehensive_resource = current_comprehensive_resource @baseline_comprehensive_resource = baseline_comprehensive_resource end |
Instance Attribute Details
#baseline_comprehensive_resource ⇒ Object (readonly)
Returns the value of attribute baseline_comprehensive_resource.
6 7 8 |
# File 'lib/reactor_sdk/resources/library_comparison_entry.rb', line 6 def baseline_comprehensive_resource @baseline_comprehensive_resource end |
#baseline_library_id ⇒ Object (readonly)
Returns the value of attribute baseline_library_id.
6 7 8 |
# File 'lib/reactor_sdk/resources/library_comparison_entry.rb', line 6 def baseline_library_id @baseline_library_id end |
#baseline_resource ⇒ Object (readonly)
Returns the value of attribute baseline_resource.
6 7 8 |
# File 'lib/reactor_sdk/resources/library_comparison_entry.rb', line 6 def baseline_resource @baseline_resource end |
#baseline_revision_id ⇒ Object (readonly)
Returns the value of attribute baseline_revision_id.
6 7 8 |
# File 'lib/reactor_sdk/resources/library_comparison_entry.rb', line 6 def baseline_revision_id @baseline_revision_id end |
#current_comprehensive_resource ⇒ Object (readonly)
Returns the value of attribute current_comprehensive_resource.
6 7 8 |
# File 'lib/reactor_sdk/resources/library_comparison_entry.rb', line 6 def current_comprehensive_resource @current_comprehensive_resource end |
#current_library_id ⇒ Object (readonly)
Returns the value of attribute current_library_id.
6 7 8 |
# File 'lib/reactor_sdk/resources/library_comparison_entry.rb', line 6 def current_library_id @current_library_id end |
#current_resource ⇒ Object (readonly)
Returns the value of attribute current_resource.
6 7 8 |
# File 'lib/reactor_sdk/resources/library_comparison_entry.rb', line 6 def current_resource @current_resource end |
#current_revision_id ⇒ Object (readonly)
Returns the value of attribute current_revision_id.
6 7 8 |
# File 'lib/reactor_sdk/resources/library_comparison_entry.rb', line 6 def current_revision_id @current_revision_id end |
#resource_id ⇒ Object (readonly)
Returns the value of attribute resource_id.
6 7 8 |
# File 'lib/reactor_sdk/resources/library_comparison_entry.rb', line 6 def resource_id @resource_id end |
#resource_type ⇒ Object (readonly)
Returns the value of attribute resource_type.
6 7 8 |
# File 'lib/reactor_sdk/resources/library_comparison_entry.rb', line 6 def resource_type @resource_type end |
Instance Method Details
#added? ⇒ Boolean
56 57 58 |
# File 'lib/reactor_sdk/resources/library_comparison_entry.rb', line 56 def added? present_in_current? && !present_in_baseline? end |
#baseline_normalized_json ⇒ Object
98 99 100 |
# File 'lib/reactor_sdk/resources/library_comparison_entry.rb', line 98 def baseline_normalized_json baseline_comprehensive_resource&.normalized_json.to_s end |
#baseline_normalized_payload ⇒ Object
90 91 92 |
# File 'lib/reactor_sdk/resources/library_comparison_entry.rb', line 90 def baseline_normalized_payload baseline_comprehensive_resource&.normalized_payload end |
#changed? ⇒ Boolean
74 75 76 |
# File 'lib/reactor_sdk/resources/library_comparison_entry.rb', line 74 def changed? !unchanged? end |
#changeset_document(position: nil) ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/reactor_sdk/resources/library_comparison_entry.rb', line 102 def changeset_document(position: nil) document = { path: changeset_path, language: 'json', old_content: baseline_normalized_json, new_content: current_normalized_json, metadata: } document[:position] = position unless position.nil? document end |
#current_normalized_json ⇒ Object
94 95 96 |
# File 'lib/reactor_sdk/resources/library_comparison_entry.rb', line 94 def current_normalized_json current_comprehensive_resource&.normalized_json.to_s end |
#current_normalized_payload ⇒ Object
86 87 88 |
# File 'lib/reactor_sdk/resources/library_comparison_entry.rb', line 86 def current_normalized_payload current_comprehensive_resource&.normalized_payload end |
#modified? ⇒ Boolean
64 65 66 |
# File 'lib/reactor_sdk/resources/library_comparison_entry.rb', line 64 def modified? present_in_current? && present_in_baseline? && !unchanged? end |
#present_in_baseline? ⇒ Boolean
82 83 84 |
# File 'lib/reactor_sdk/resources/library_comparison_entry.rb', line 82 def present_in_baseline? !baseline_resource.nil? end |
#present_in_current? ⇒ Boolean
78 79 80 |
# File 'lib/reactor_sdk/resources/library_comparison_entry.rb', line 78 def present_in_current? !current_resource.nil? end |
#removed? ⇒ Boolean
60 61 62 |
# File 'lib/reactor_sdk/resources/library_comparison_entry.rb', line 60 def removed? !present_in_current? && present_in_baseline? end |
#resource_name ⇒ Object
41 42 43 44 45 46 |
# File 'lib/reactor_sdk/resources/library_comparison_entry.rb', line 41 def resource_name return current_resource.name if current_resource.respond_to?(:name) return baseline_resource.name if baseline_resource.respond_to?(:name) nil end |
#status ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/reactor_sdk/resources/library_comparison_entry.rb', line 48 def status return 'added' if added? return 'removed' if removed? return 'unchanged' if unchanged? 'modified' end |
#unchanged? ⇒ Boolean
68 69 70 71 72 |
# File 'lib/reactor_sdk/resources/library_comparison_entry.rb', line 68 def unchanged? return false unless present_in_current? && present_in_baseline? same_revision? || same_normalized_payload? end |