Class: GraphQL::Doctor::Diagnostic
- Inherits:
-
Struct
- Object
- Struct
- GraphQL::Doctor::Diagnostic
- Defined in:
- lib/graphql/doctor/diagnostic.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#fingerprint ⇒ Object
Returns the value of attribute fingerprint.
-
#location ⇒ Object
Returns the value of attribute location.
-
#message ⇒ Object
Returns the value of attribute message.
-
#notes ⇒ Object
Returns the value of attribute notes.
-
#severity ⇒ Object
Returns the value of attribute severity.
-
#suggestions ⇒ Object
Returns the value of attribute suggestions.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(suggestions: [], notes: [], **attributes) ⇒ Diagnostic
constructor
A new instance of Diagnostic.
- #to_h ⇒ Object
Constructor Details
#initialize(suggestions: [], notes: [], **attributes) ⇒ Diagnostic
Returns a new instance of Diagnostic.
22 23 24 25 |
# File 'lib/graphql/doctor/diagnostic.rb', line 22 def initialize(suggestions: [], notes: [], **attributes) super(suggestions: suggestions.freeze, notes: notes.freeze, **attributes) freeze end |
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code
18 19 20 |
# File 'lib/graphql/doctor/diagnostic.rb', line 18 def code @code end |
#fingerprint ⇒ Object
Returns the value of attribute fingerprint
18 19 20 |
# File 'lib/graphql/doctor/diagnostic.rb', line 18 def fingerprint @fingerprint end |
#location ⇒ Object
Returns the value of attribute location
18 19 20 |
# File 'lib/graphql/doctor/diagnostic.rb', line 18 def location @location end |
#message ⇒ Object
Returns the value of attribute message
18 19 20 |
# File 'lib/graphql/doctor/diagnostic.rb', line 18 def @message end |
#notes ⇒ Object
Returns the value of attribute notes
18 19 20 |
# File 'lib/graphql/doctor/diagnostic.rb', line 18 def notes @notes end |
#severity ⇒ Object
Returns the value of attribute severity
18 19 20 |
# File 'lib/graphql/doctor/diagnostic.rb', line 18 def severity @severity end |
#suggestions ⇒ Object
Returns the value of attribute suggestions
18 19 20 |
# File 'lib/graphql/doctor/diagnostic.rb', line 18 def suggestions @suggestions end |
Class Method Details
.from_h(hash) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/graphql/doctor/diagnostic.rb', line 27 def self.from_h(hash) values = hash.transform_keys(&:to_sym) values[:location] = Location.from_h(values[:location]) if values[:location] values[:suggestions] = Array(values[:suggestions]).map do |suggestion| suggestion = suggestion.transform_keys(&:to_sym) suggestion[:location] = Location.from_h(suggestion[:location]) if suggestion[:location] Suggestion.new(**suggestion) end new(**values) end |
Instance Method Details
#to_h ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/graphql/doctor/diagnostic.rb', line 38 def to_h { code: code, severity: severity.to_s, message: , location: location&.to_h, suggestions: suggestions.map(&:to_h), notes: notes, fingerprint: fingerprint }.compact end |