Module: Sidebars::Concerns::HasPill

Includes:
ActionView::Helpers::NumberHelper
Included in:
IssuablesHelper, Menu
Defined in:
lib/sidebars/concerns/has_pill.rb

Instance Method Summary collapse

Instance Method Details

#format_cached_count(threshold, count) ⇒ Object


24
25
26
27
28
29
30
31
32
33
# File 'lib/sidebars/concerns/has_pill.rb', line 24

def format_cached_count(threshold, count)
  if count > threshold
    number_to_human(
      count,
      units: { thousand: 'k', million: 'm' }, precision: 1, significant: false, format: '%n%u'
    )
  else
    number_with_delimiter(count)
  end
end

#has_pill?Boolean

Returns:

  • (Boolean)

10
11
12
# File 'lib/sidebars/concerns/has_pill.rb', line 10

def has_pill?
  false
end

#pill_countObject

In this method we will need to provide the query to retrieve the elements count

Raises:

  • (NotImplementedError)

16
17
18
# File 'lib/sidebars/concerns/has_pill.rb', line 16

def pill_count
  raise NotImplementedError
end

#pill_html_optionsObject


20
21
22
# File 'lib/sidebars/concerns/has_pill.rb', line 20

def pill_html_options
  {}
end