Class: Necropsy::Resolution
- Inherits:
-
Data
- Object
- Data
- Necropsy::Resolution
- Defined in:
- lib/necropsy/models.rb
Instance Attribute Summary collapse
-
#call_site_id ⇒ Object
readonly
Returns the value of attribute call_site_id.
-
#evidence_ids ⇒ Object
readonly
Returns the value of attribute evidence_ids.
-
#rejected_targets ⇒ Object
readonly
Returns the value of attribute rejected_targets.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#target_definition_ids ⇒ Object
readonly
Returns the value of attribute target_definition_ids.
-
#unknown_scope ⇒ Object
readonly
Returns the value of attribute unknown_scope.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(call_site_id:, target_definition_ids:, status:, unknown_scope: nil, rejected_targets: [], evidence_ids: []) ⇒ Resolution
constructor
A new instance of Resolution.
- #to_h ⇒ Object
Constructor Details
#initialize(call_site_id:, target_definition_ids:, status:, unknown_scope: nil, rejected_targets: [], evidence_ids: []) ⇒ Resolution
Returns a new instance of Resolution.
166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/necropsy/models.rb', line 166 def initialize(call_site_id:, target_definition_ids:, status:, unknown_scope: nil, rejected_targets: [], evidence_ids: []) call_site_id = ModelNormalization.identifier(call_site_id, 'call_site_id') target_definition_ids = ModelNormalization.string_list(target_definition_ids, 'target_definition_id') status = status.to_sym if status.respond_to?(:to_sym) raise ArgumentError, "invalid resolution status: #{status.inspect}" unless RESOLUTION_STATUSES.include?(status) unknown_scope = normalize_unknown_scope(unknown_scope) rejected_targets = normalize_rejected_targets(rejected_targets) evidence_ids = ModelNormalization.string_list(evidence_ids, 'evidence_id') validate_state!(status, target_definition_ids, unknown_scope) super end |
Instance Attribute Details
#call_site_id ⇒ Object (readonly)
Returns the value of attribute call_site_id
158 159 160 |
# File 'lib/necropsy/models.rb', line 158 def call_site_id @call_site_id end |
#evidence_ids ⇒ Object (readonly)
Returns the value of attribute evidence_ids
158 159 160 |
# File 'lib/necropsy/models.rb', line 158 def evidence_ids @evidence_ids end |
#rejected_targets ⇒ Object (readonly)
Returns the value of attribute rejected_targets
158 159 160 |
# File 'lib/necropsy/models.rb', line 158 def rejected_targets @rejected_targets end |
#status ⇒ Object (readonly)
Returns the value of attribute status
158 159 160 |
# File 'lib/necropsy/models.rb', line 158 def status @status end |
#target_definition_ids ⇒ Object (readonly)
Returns the value of attribute target_definition_ids
158 159 160 |
# File 'lib/necropsy/models.rb', line 158 def target_definition_ids @target_definition_ids end |
#unknown_scope ⇒ Object (readonly)
Returns the value of attribute unknown_scope
158 159 160 |
# File 'lib/necropsy/models.rb', line 158 def unknown_scope @unknown_scope end |
Class Method Details
.from_h(attributes) ⇒ Object
180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/necropsy/models.rb', line 180 def self.from_h(attributes) data = ModelNormalization.attributes(attributes, name) new( call_site_id: data.fetch('call_site_id'), target_definition_ids: data.fetch('target_definition_ids', []), status: data.fetch('status'), unknown_scope: data['unknown_scope'], rejected_targets: data.fetch('rejected_targets', []), evidence_ids: data.fetch('evidence_ids', []) ) end |
Instance Method Details
#to_h ⇒ Object
192 193 194 195 196 197 198 199 200 201 |
# File 'lib/necropsy/models.rb', line 192 def to_h { 'call_site_id' => call_site_id, 'target_definition_ids' => target_definition_ids, 'status' => status.to_s, 'unknown_scope' => unknown_scope&.to_h, 'rejected_targets' => rejected_targets.map(&:to_h), 'evidence_ids' => evidence_ids } end |