Re: [HACKERS] TAP: allow overriding PostgresNode in get_new_node
От | Craig Ringer |
---|---|
Тема | Re: [HACKERS] TAP: allow overriding PostgresNode in get_new_node |
Дата | |
Msg-id | CAMsr+YEpQLxXPW-9sd6ey4Ddsm2=xFHB2F2GaHbx6o9HzTksCA@mail.gmail.com обсуждение исходный текст |
Ответ на | [HACKERS] TAP: allow overriding PostgresNode in get_new_node (Craig Ringer <craig@2ndquadrant.com>) |
Ответы |
Re: [HACKERS] TAP: allow overriding PostgresNode in get_new_node
|
Список | pgsql-hackers |
On 31 May 2017 at 08:43, Craig Ringer <craig@2ndquadrant.com> wrote: > Hi all > > More and more I'm finding it useful to extend PostgresNode for project > specific helper classes. But PostgresNode::get_new_node is a factory > that doesn't provide any mechanism for overriding, so you have to > create a PostgresNode then re-bless it as your desired subclass. Ugly. > > The attached patch allows an optional second argument, a class name, > to be passed to PostgresNode::get_new_node . It's instantiated instead > of PostgresNode if supplied. Its 'new' constructor must take the same > arguments. Note that you can achieve the same effect w/o patching PostgresNode.pm, albeit in a somewhat ugly manner, by re-blessing the returned object. sub get_new_mywhatever_node { my $self = PostgresNode::get_new_node($name); $self = bless $self, 'MyWhateverNode'; return $self; } so this would be cosmetically nice, but far from functionally vital. -- Craig Ringer http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training & Services
В списке pgsql-hackers по дате отправления: