Class: ProblemCheck::Problem
- Inherits:
-
Object
- Object
- ProblemCheck::Problem
- Defined in:
- app/services/problem_check/problem.rb
Constant Summary collapse
- PRIORITIES =
%w[low high].freeze
Instance Attribute Summary collapse
-
#details ⇒ Object
readonly
Returns the value of attribute details.
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#priority ⇒ Object
readonly
Returns the value of attribute priority.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(message, priority: "low", identifier: nil, target: nil, details: {}) ⇒ Problem
constructor
A new instance of Problem.
- #to_h ⇒ Object (also: #attributes)
- #to_s ⇒ Object
Constructor Details
#initialize(message, priority: "low", identifier: nil, target: nil, details: {}) ⇒ Problem
Returns a new instance of Problem.
8 9 10 11 12 13 14 |
# File 'app/services/problem_check/problem.rb', line 8 def initialize(, priority: "low", identifier: nil, target: nil, details: {}) @message = @priority = PRIORITIES.include?(priority) ? priority : "low" @identifier = identifier @target = target @details = details end |
Instance Attribute Details
#details ⇒ Object (readonly)
Returns the value of attribute details.
6 7 8 |
# File 'app/services/problem_check/problem.rb', line 6 def details @details end |
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
6 7 8 |
# File 'app/services/problem_check/problem.rb', line 6 def identifier @identifier end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
6 7 8 |
# File 'app/services/problem_check/problem.rb', line 6 def @message end |
#priority ⇒ Object (readonly)
Returns the value of attribute priority.
6 7 8 |
# File 'app/services/problem_check/problem.rb', line 6 def priority @priority end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
6 7 8 |
# File 'app/services/problem_check/problem.rb', line 6 def target @target end |
Class Method Details
.from_h(h) ⇒ Object
25 26 27 28 29 30 31 |
# File 'app/services/problem_check/problem.rb', line 25 def self.from_h(h) h = h.with_indifferent_access return if h[:message].blank? new(h[:message], priority: h[:priority], identifier: h[:identifier]) end |
Instance Method Details
#to_h ⇒ Object Also known as: attributes
20 21 22 |
# File 'app/services/problem_check/problem.rb', line 20 def to_h { message: , priority: priority, identifier: identifier } end |
#to_s ⇒ Object
16 17 18 |
# File 'app/services/problem_check/problem.rb', line 16 def to_s @message end |