Class: Necropsy::Root
- Inherits:
-
Data
- Object
- Data
- Necropsy::Root
- Defined in:
- lib/necropsy/models.rb
Instance Attribute Summary collapse
-
#definition_id ⇒ Object
(also: #node_id)
readonly
Returns the value of attribute definition_id.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#evidence ⇒ Object
readonly
Returns the value of attribute evidence.
-
#reason ⇒ Object
readonly
Returns the value of attribute reason.
Class Method Summary collapse
Instance Method Summary collapse
- #external? ⇒ Boolean
-
#initialize(reason:, definition_id: nil, node_id: nil, domain: nil, evidence: nil) ⇒ Root
constructor
A new instance of Root.
- #runtime? ⇒ Boolean
- #test? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(reason:, definition_id: nil, node_id: nil, domain: nil, evidence: nil) ⇒ Root
Returns a new instance of Root.
543 544 545 546 547 548 549 550 551 552 553 554 555 556 |
# File 'lib/necropsy/models.rb', line 543 def initialize(reason:, definition_id: nil, node_id: nil, domain: nil, evidence: nil) definition_id ||= node_id definition_id = ModelNormalization.identifier(definition_id, 'definition_id') reason = ModelNormalization.identifier(reason, 'reason').to_sym domain ||= reason == :test_suite ? :test : :runtime domain = domain.to_sym if domain.respond_to?(:to_sym) raise ArgumentError, "invalid root domain: #{domain.inspect}" unless ROOT_DOMAINS.include?(domain) evidence ||= { 'type' => 'entry_point', 'reason' => reason.to_s } evidence = evidence.to_h if evidence.respond_to?(:to_h) raise ArgumentError, 'root evidence must be a Hash' unless evidence.is_a?(Hash) super(definition_id: definition_id, domain: domain, reason: reason, evidence: evidence.freeze) end |
Instance Attribute Details
#definition_id ⇒ Object (readonly) Also known as: node_id
Returns the value of attribute definition_id
529 530 531 |
# File 'lib/necropsy/models.rb', line 529 def definition_id @definition_id end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain
529 530 531 |
# File 'lib/necropsy/models.rb', line 529 def domain @domain end |
#evidence ⇒ Object (readonly)
Returns the value of attribute evidence
529 530 531 |
# File 'lib/necropsy/models.rb', line 529 def evidence @evidence end |
#reason ⇒ Object (readonly)
Returns the value of attribute reason
529 530 531 |
# File 'lib/necropsy/models.rb', line 529 def reason @reason end |
Class Method Details
.data_new ⇒ Object
531 |
# File 'lib/necropsy/models.rb', line 531 alias_method :data_new, :new |
.new(*values, **attributes) ⇒ Object Also known as: []
533 534 535 536 537 |
# File 'lib/necropsy/models.rb', line 533 def new(*values, **attributes) return data_new(node_id: values[0], reason: values[1]) if values.length == 2 && attributes.empty? data_new(*values, **attributes) end |
Instance Method Details
#external? ⇒ Boolean
568 569 570 |
# File 'lib/necropsy/models.rb', line 568 def external? domain == :external end |
#runtime? ⇒ Boolean
564 565 566 |
# File 'lib/necropsy/models.rb', line 564 def runtime? domain == :runtime end |
#test? ⇒ Boolean
560 561 562 |
# File 'lib/necropsy/models.rb', line 560 def test? domain == :test end |
#to_h ⇒ Object
572 573 574 575 576 577 578 579 580 |
# File 'lib/necropsy/models.rb', line 572 def to_h { 'node_id' => node_id, 'definition_id' => definition_id, 'domain' => domain.to_s, 'reason' => reason.to_s, 'evidence' => evidence } end |