Class: Necropsy::MethodLookup
- Inherits:
-
Data
- Object
- Data
- Necropsy::MethodLookup
- Defined in:
- lib/necropsy/models.rb
Instance Attribute Summary collapse
-
#lookup_chain ⇒ Object
readonly
Returns the value of attribute lookup_chain.
-
#reason ⇒ Object
readonly
Returns the value of attribute reason.
-
#rejected_targets ⇒ Object
readonly
Returns the value of attribute rejected_targets.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#targets ⇒ Object
readonly
Returns the value of attribute targets.
Instance Method Summary collapse
- #complete? ⇒ Boolean
-
#initialize(targets:, status:, rejected_targets: [], lookup_chain: [], reason: nil) ⇒ MethodLookup
constructor
A new instance of MethodLookup.
- #partial? ⇒ Boolean
- #to_h ⇒ Object
- #unknown? ⇒ Boolean
Constructor Details
#initialize(targets:, status:, rejected_targets: [], lookup_chain: [], reason: nil) ⇒ MethodLookup
Returns a new instance of MethodLookup.
373 374 375 376 377 378 379 380 381 382 383 |
# File 'lib/necropsy/models.rb', line 373 def initialize(targets:, status:, rejected_targets: [], lookup_chain: [], reason: nil) status = status.to_sym raise ArgumentError, "invalid method lookup status: #{status.inspect}" unless RESOLUTION_STATUSES.include?(status) targets = Array(targets).uniq(&:graph_id).sort_by(&:graph_id).freeze rejected_targets = Array(rejected_targets).uniq.sort_by do |target| [target.definition_id, target.reason, target.evidence_ids] end.freeze lookup_chain = Array(lookup_chain).map(&:to_s).freeze super end |
Instance Attribute Details
#lookup_chain ⇒ Object (readonly)
Returns the value of attribute lookup_chain
366 367 368 |
# File 'lib/necropsy/models.rb', line 366 def lookup_chain @lookup_chain end |
#reason ⇒ Object (readonly)
Returns the value of attribute reason
366 367 368 |
# File 'lib/necropsy/models.rb', line 366 def reason @reason end |
#rejected_targets ⇒ Object (readonly)
Returns the value of attribute rejected_targets
366 367 368 |
# File 'lib/necropsy/models.rb', line 366 def rejected_targets @rejected_targets end |
#status ⇒ Object (readonly)
Returns the value of attribute status
366 367 368 |
# File 'lib/necropsy/models.rb', line 366 def status @status end |
#targets ⇒ Object (readonly)
Returns the value of attribute targets
366 367 368 |
# File 'lib/necropsy/models.rb', line 366 def targets @targets end |
Instance Method Details
#complete? ⇒ Boolean
385 386 387 |
# File 'lib/necropsy/models.rb', line 385 def complete? status == :complete end |
#partial? ⇒ Boolean
389 390 391 |
# File 'lib/necropsy/models.rb', line 389 def partial? status == :partial end |
#to_h ⇒ Object
397 398 399 400 401 402 403 404 405 |
# File 'lib/necropsy/models.rb', line 397 def to_h { 'target_definition_ids' => targets.map(&:graph_id), 'status' => status.to_s, 'rejected_targets' => rejected_targets.map(&:to_h), 'lookup_chain' => lookup_chain, 'reason' => reason } end |
#unknown? ⇒ Boolean
393 394 395 |
# File 'lib/necropsy/models.rb', line 393 def unknown? status == :unknown end |