Module: Tracebook::ChatsHelper

Defined in:
app/helpers/tracebook/chats_helper.rb

Instance Method Summary collapse

Instance Method Details

#actor_name(chat) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'app/helpers/tracebook/chats_helper.rb', line 18

def actor_name(chat)
  actor = chat.try(:user)
  return "" unless actor

  if Tracebook.config.actor_display
    Tracebook.config.actor_display.call(actor)
  else
    actor.try(:name) || actor.try(:email) || "#{actor.class.name}##{actor.id}"
  end
end

#cents_to_human(cents) ⇒ Object



5
6
7
# File 'app/helpers/tracebook/chats_helper.rb', line 5

def cents_to_human(cents)
  number_to_currency(cents.to_f / 100.0)
end

#review_badge(review_state) ⇒ Object



9
10
11
12
13
14
15
16
# File 'app/helpers/tracebook/chats_helper.rb', line 9

def review_badge(review_state)
  css_class = case review_state.to_s
  when "approved" then "tb-status tb-status-success"
  when "flagged" then "tb-status tb-status-error"
  else "tb-status tb-status-pending"
  end
  (:span, review_state, class: css_class)
end