Module: Capybara::ActiveAdmin::Util

Defined in:
lib/capybara/active_admin/util.rb

Class Method Summary collapse

Class Method Details

.options_with_text(text, options = {}) ⇒ Object



16
17
18
19
20
# File 'lib/capybara/active_admin/util.rb', line 16

def options_with_text(text, options = {})
  key = options[:exact] ? :exact_text : :text

  options.except(:exact).merge(key => text)
end

.parse_model_name(model_name, singular: true) ⇒ Object

Common pure utility functions



8
9
10
11
12
13
14
# File 'lib/capybara/active_admin/util.rb', line 8

def parse_model_name(model_name, singular: true)
  return if model_name.nil?

  model_name = model_name.model_name.singular if model_name.is_a?(Class)
  model_name = model_name.to_s.gsub(' ', '_').downcase
  singular ? model_name.singularize : model_name.pluralize
end