Project

General

Profile

Actions

Feature #13733

open

Dump the delegator instead of the delegated object

Added by huynhquancam (Cam Huynh) over 7 years ago. Updated over 6 years ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:81970]

Description

I would like to let Delegator dump itself instead of the delegated object.

Let's consider the following scenario.

require "delegate"

class Foo < Delegator
  def initialize(the_obj)
    @the_obj = the_obj
  end

  def __getobj__
    @the_obj
  end
end

foo = Foo.new(nil)
foo.inspect
# nil

This dump message might cause confusion because foo object itself is not nil. Why don't we be clear and have a dump message like "foo is an Foo class with nil as the delegated object"?

I have submitted an PR on https://github.com/ruby/ruby/pull/1653 for your reference.

Updated by yuki24 (Yuki Nishijima) over 6 years ago

I like this idea, but I may be missing something. Could anyone have any objections or points that we are not aware of?

Actions

Also available in: Atom PDF

Like0
Like0