Class: AdminDashboardData::Problem
- Inherits:
-
Object
- Object
- AdminDashboardData::Problem
- Defined in:
- app/models/admin_dashboard_data.rb
Constant Summary collapse
- VALID_PRIORITIES =
%w[low high].freeze
Instance Attribute Summary collapse
-
#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.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(message, priority: "low", identifier: nil) ⇒ Problem
constructor
A new instance of Problem.
- #to_h ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(message, priority: "low", identifier: nil) ⇒ Problem
Returns a new instance of Problem.
13 14 15 16 17 |
# File 'app/models/admin_dashboard_data.rb', line 13 def initialize(, priority: "low", identifier: nil) @message = @priority = VALID_PRIORITIES.include?(priority) ? priority : "low" @identifier = identifier end |
Instance Attribute Details
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
11 12 13 |
# File 'app/models/admin_dashboard_data.rb', line 11 def identifier @identifier end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
11 12 13 |
# File 'app/models/admin_dashboard_data.rb', line 11 def @message end |
#priority ⇒ Object (readonly)
Returns the value of attribute priority.
11 12 13 |
# File 'app/models/admin_dashboard_data.rb', line 11 def priority @priority end |
Class Method Details
.from_h(h) ⇒ Object
27 28 29 30 31 |
# File 'app/models/admin_dashboard_data.rb', line 27 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
23 24 25 |
# File 'app/models/admin_dashboard_data.rb', line 23 def to_h { message: , priority: priority, identifier: identifier } end |
#to_s ⇒ Object
19 20 21 |
# File 'app/models/admin_dashboard_data.rb', line 19 def to_s @message end |