Sha256: 8f5efccd1fd8d9bb18e4d883cdd6d222e9adffdce1ad70977209e7001a1b90c3
Contents?: true
Size: 1.05 KB
Versions: 13
Compression:
Stored size: 1.05 KB
Contents
# frozen_string_literal: true module RailsAdmin module Config module Inspectable def inspect set_named_instance_variables instance_name = try(:name) || try(:abstract_model).try(:model).try(:name) instance_name = instance_name ? "[#{instance_name}]" : '' instance_vars = instance_variables.collect do |v| instance_variable_name(v) end.join(', ') "#<#{self.class.name}#{instance_name} #{instance_vars}>" end private def instance_variable_name(variable) value = instance_variable_get(variable) if self.class::NAMED_INSTANCE_VARIABLES.include?(variable) if value.respond_to?(:name) "#{variable}=#{value.name.inspect}" else "#{variable}=#{value.class.name}" end else "#{variable}=#{value.inspect}" end end def set_named_instance_variables self.class.const_set('NAMED_INSTANCE_VARIABLES', []) unless defined?(self.class::NAMED_INSTANCE_VARIABLES) end end end end
Version data entries
13 entries across 13 versions & 1 rubygems