Class: AdminDashboardData::Problem

Inherits:
Object
  • Object
show all
Defined in:
app/models/admin_dashboard_data.rb

Constant Summary collapse

VALID_PRIORITIES =
%w[low high].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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(message, priority: "low", identifier: nil)
  @message = message
  @priority = VALID_PRIORITIES.include?(priority) ? priority : "low"
  @identifier = identifier
end

Instance Attribute Details

#identifierObject (readonly)

Returns the value of attribute identifier.



11
12
13
# File 'app/models/admin_dashboard_data.rb', line 11

def identifier
  @identifier
end

#messageObject (readonly)

Returns the value of attribute message.



11
12
13
# File 'app/models/admin_dashboard_data.rb', line 11

def message
  @message
end

#priorityObject (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_hObject



23
24
25
# File 'app/models/admin_dashboard_data.rb', line 23

def to_h
  { message: message, priority: priority, identifier: identifier }
end

#to_sObject



19
20
21
# File 'app/models/admin_dashboard_data.rb', line 19

def to_s
  @message
end