Sha256: 819bdc96ffc2dc04a7578f64529f9625e9c85f0711431145c356ffcb0d26ba49

Contents?: true

Size: 669 Bytes

Versions: 4

Compression:

Stored size: 669 Bytes

Contents

# frozen_string_literal: true

module Capybara
  module ActiveAdmin
    module Util
      # Common pure utility functions

      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

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

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

      module_function :parse_model_name, :options_with_text
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
capybara_active_admin-0.3.3 lib/capybara/active_admin/util.rb
capybara_active_admin-0.3.2 lib/capybara/active_admin/util.rb
capybara_active_admin-0.3.1 lib/capybara/active_admin/util.rb
capybara_active_admin-0.3.0 lib/capybara/active_admin/util.rb