Class: Lit::Services::HumanizeService

Inherits:
Object
  • Object
show all
Defined in:
lib/lit/services/humanize_service.rb

Overview

Checks if should humanize based on config and blacklist. Performs humanize if required Caches the value of humanization

Class Method Summary collapse

Class Method Details

.humanize(key) ⇒ Object



13
14
15
# File 'lib/lit/services/humanize_service.rb', line 13

def self.humanize(key)
  key.to_s.split('.').last.humanize
end

.humanize_and_cache(key, options) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/lit/services/humanize_service.rb', line 17

def self.humanize_and_cache(key, options)
  content = humanize(key)
  parts = I18n.normalize_keys(
    options[:locale] || I18n.locale, key, options[:scope], options[:separator]
  )
  key_with_locale = parts.join('.')
  I18n.cache_store[key_with_locale] = content
  I18n.cache_store[key_with_locale]
end

.should_humanize?(key) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/lit/services/humanize_service.rb', line 9

def self.should_humanize?(key)
  Lit.humanize_key && Lit.humanize_key_ignored.match(key).nil?
end