class Object

Public Instance Methods

call() click to toggle source
# File lib/helium/console/rails/registry/active_record.rb, line 3
def call
  primary_key = object.class.primary_key

  table = Helium::Console::Table.new(runner: '| ', after_key: ": ", format_keys: false)
  table.row(primary_key, object.attributes[primary_key]) if primary_key

  object.attributes.sort_by(&:first).each do |key, value|
    next if key == primary_key
    table.row(key.to_s, value)
  end
  [
    "# #{object.class.name}",
    format(table, **options)
  ].join($/)
end
format_record(record) click to toggle source
# File lib/helium/console/rails/registry/active_record_relation.rb, line 14
def format_record(record)
  table = Helium::Console::Table.new(runner: '| ', after_key: ": ", format_keys: false)
  table.row(primary_key, record.attributes[primary_key]) if primary_key

  record.attributes.sort_by(&:first).each do |key, value|
    next if key == primary_key
    table.row(key.to_s, value)
  end

  format(table, **options, max_width: max_width - 2)
end
primary_key() click to toggle source
# File lib/helium/console/rails/registry/active_record_relation.rb, line 26
def primary_key
  object.klass.primary_key
end