module Acts::DataTable

Constants

I18n_LOCALES

Public Class Methods

ensure_nested_hash!(hash, *keys) click to toggle source
# File lib/acts_as_data_table.rb, line 32
def self.ensure_nested_hash!(hash, *keys)
  h = hash
  keys.each do |key|
    h[key] ||= {}
    h = h[key]
  end
end
log(level, message) click to toggle source
# File lib/acts_as_data_table.rb, line 28
def self.log(level, message)
  Rails.logger.send(level, "Acts::DataTable [#{level}] -- #{message}")
end
lookup_nested_hash(hash, *keys) click to toggle source
# File lib/acts_as_data_table.rb, line 40
def self.lookup_nested_hash(hash, *keys)
  return nil if hash.nil?

  h = hash
  keys.each do |key|
    return nil if h[key].nil?
    h = h[key]
  end
  h
end
t(key, options = {}) click to toggle source

Retrieves a value from the gem's locale namespace. If there are no translations for the application's locale, the english versions are used.

# File lib/acts_as_data_table.rb, line 56
def self.t(key, options = {})
  locale = I18n_LOCALES.include?(I18n.locale.to_s) ? I18n.locale : 'en'
  I18n.t(key, options.merge({:scope => 'acts_as_data_table', :locale => locale}))
end