class RailsAdmin::Config::Model
Model
specific configuration object.
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 26 def initialize(entity) @parent = nil @root = self @abstract_model = begin if entity.kind_of?(RailsAdmin::AbstractModel) entity elsif entity.kind_of?(Class) || entity.kind_of?(String) || entity.kind_of?(Symbol) RailsAdmin::AbstractModel.new(entity) else RailsAdmin::AbstractModel.new(entity.class) end 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 42 def excluded? @excluded ||= !RailsAdmin::AbstractModel.all.map(&:model_name).include?(abstract_model.try(:model_name)) end
inspect()
click to toggle source
# File lib/rails_admin/config/model.rb, line 91 def inspect "#<#{self.class.name}[#{abstract_model.model.name}] #{ instance_variables.map do |v| value = instance_variable_get(v) if [:@parent, :@root].include? v if value.respond_to? :name "#{v}=#{value.name.inspect}" else "#{v}=#{value.class.name}" end else "#{v}=#{value.inspect}" end end.join(", ") }>" end
method_missing(m, *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 87 def method_missing(m, *args, &block) self.send(:base).send(m, *args, &block) end
object_label()
click to toggle source
# File lib/rails_admin/config/model.rb, line 46 def object_label bindings[:object].send object_label_method end
pluralize(count)
click to toggle source
# File lib/rails_admin/config/model.rb, line 66 def pluralize(count) count == 1 ? label : label_plural end