Class: ExceptionHunter::DashboardPresenter

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/exception_hunter/dashboard_presenter.rb

Constant Summary collapse

LAST_7_DAYS_TAB =
'last_7_days'.freeze
CURRENT_MONTH_TAB =
'current_month'.freeze
TOTAL_ERRORS_TAB =
'total_errors'.freeze
RESOLVED_ERRORS_TAB =
'resolved'.freeze
IGNORED_ERRORS_TAB =
'ignored'.freeze
TABS =
[LAST_7_DAYS_TAB, CURRENT_MONTH_TAB, TOTAL_ERRORS_TAB, RESOLVED_ERRORS_TAB, IGNORED_ERRORS_TAB].freeze
DEFAULT_TAB =
LAST_7_DAYS_TAB

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(current_tab) ⇒ DashboardPresenter

Returns a new instance of DashboardPresenter.



13
14
15
16
# File 'app/presenters/exception_hunter/dashboard_presenter.rb', line 13

def initialize(current_tab)
  assign_tab(current_tab)
  calculate_tabs_counts
end

Instance Attribute Details

#current_tabObject (readonly)



11
12
13
# File 'app/presenters/exception_hunter/dashboard_presenter.rb', line 11

def current_tab
  @current_tab
end

Instance Method Details

#errors_count(tab) ⇒ Object



31
32
33
# File 'app/presenters/exception_hunter/dashboard_presenter.rb', line 31

def errors_count(tab)
  @tabs_counts[tab]
end

#partial_for_tabObject



22
23
24
25
26
27
28
29
# File 'app/presenters/exception_hunter/dashboard_presenter.rb', line 22

def partial_for_tab
  case current_tab
  when LAST_7_DAYS_TAB
    'exception_hunter/errors/last_7_days_errors_table'
  when CURRENT_MONTH_TAB, TOTAL_ERRORS_TAB, RESOLVED_ERRORS_TAB, IGNORED_ERRORS_TAB
    'exception_hunter/errors/errors_table'
  end
end

#tab_active?(tab) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'app/presenters/exception_hunter/dashboard_presenter.rb', line 18

def tab_active?(tab)
  tab == current_tab
end