Module: Acts::DataTable

Defined in:
lib/acts_as_data_table.rb,
lib/acts_as_data_table/shared/session.rb,
lib/acts_as_data_table/multi_column_scopes.rb,
lib/acts_as_data_table/scope_filters/validator.rb,
lib/acts_as_data_table/shared/action_controller.rb,
lib/acts_as_data_table/scope_filters/form_helper.rb,
lib/acts_as_data_table/scope_filters/active_record.rb,
lib/acts_as_data_table/sortable_columns/active_record.rb,
lib/acts_as_data_table/scope_filters/action_controller.rb,
lib/acts_as_data_table/sortable_columns/action_controller.rb,
lib/acts_as_data_table/sortable_columns/renderers/default.rb,
lib/acts_as_data_table/sortable_columns/renderers/bootstrap2.rb,
lib/acts_as_data_table/sortable_columns/renderers/bootstrap3.rb

Defined Under Namespace

Modules: MultiColumnScopes, ScopeFilters, Shared, SortableColumns

Constant Summary collapse

I18n_LOCALES =
%w(en)

Class Method Summary collapse

Class Method Details

.ensure_nested_hash!(hash, *keys) ⇒ Object



32
33
34
35
36
37
38
# 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) ⇒ Object



28
29
30
# 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) ⇒ Object



40
41
42
43
44
45
46
47
48
49
# 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 = {}) ⇒ Object

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



56
57
58
59
# 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