class RailsAdmin::Config::Model

Model specific configuration object.

Constants

NAMED_INSTANCE_VARIABLES

Attributes

abstract_model[R]
groups[RW]
parent[R]
root[R]

Public Class Methods

new(entity) click to toggle source
# File lib/rails_admin/config/model.rb, line 31
def initialize(entity)
  @parent = nil
  @root = self

  @abstract_model =
    case entity
    when RailsAdmin::AbstractModel
      entity
    when Class, String
      RailsAdmin::AbstractModel.new(entity)
    when Symbol
      RailsAdmin::AbstractModel.new(entity.to_s)
    else
      RailsAdmin::AbstractModel.new(entity.class)
    end

  @groups = [RailsAdmin::Config::Fields::Group.new(self, :default).tap { |g| g.label { I18n.translate('admin.form.basic_info') } }]
end

Public Instance Methods

excluded?() click to toggle source
# File lib/rails_admin/config/model.rb, line 50
def excluded?
  return @excluded if defined?(@excluded)

  @excluded = !RailsAdmin::AbstractModel.all.collect(&:model_name).include?(abstract_model.try(:model_name))
end
method_missing(method_name, *args, &block) click to toggle source

Act as a proxy for the base section configuration that actually store the configurations.

# File lib/rails_admin/config/model.rb, line 115
def method_missing(method_name, *args, &block)
  send(:base).send(method_name, *args, &block)
end
object_label() click to toggle source
# File lib/rails_admin/config/model.rb, line 56
def object_label
  bindings[:object].send(object_label_method).presence ||
    bindings[:object].send(:rails_admin_default_object_label_method)
end
pluralize(count) click to toggle source
# File lib/rails_admin/config/model.rb, line 77
def pluralize(count)
  count == 1 ? label : label_plural
end