Skip Menu |
 

This queue is for tickets about the Class-DBI CPAN distribution.

Report information
The Basics
Id: 13306
Status: stalled
Worked: 2 min
Priority: 0/
Queue: Class-DBI

People
Owner: Nobody in particular
Requestors: brano [...] blueorange.sk
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Return-Path: <tony [...] kasei.com>
X-Original-To: bug-Class-Dbi [...] rt.cpan.org
Delivered-To: cpan-bug+class-dbi [...] diesel.bestpractical.com
Received: from la.mx.develooper.com (x1.develooper.com [63.251.223.170]) by diesel.bestpractical.com (Postfix) with SMTP id 669604D807D for <bug-Class-Dbi [...] rt.cpan.org>; Sat, 18 Jun 2005 07:32:42 -0400 (EDT)
Received: (qmail 3870 invoked by alias); 18 Jun 2005 11:32:41 -0000
X-Spam-Check-BY: la.mx.develooper.com
Received-SPF: pass (x1.develooper.com: local policy)
Received: from soto.kasei.com (HELO soto.kasei.com) (80.76.206.154) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Sat, 18 Jun 2005 04:32:40 -0700
Received: by soto.kasei.com (Postfix, from userid 1011) id 9F6F01D012; Sat, 18 Jun 2005 12:32:36 +0100 (BST)
Resent-From: tony [...] kasei.com
Resent-Date: Sat, 18 Jun 2005 12:32:36 +0100
Resent-Message-ID: <20050618113236.GN12698 [...] soto.kasei.com>
Resent-To: bug-Class-Dbi [...] rt.cpan.org
X-Original-To: tony-cdbitalk [...] kasei.com
Received: by soto.kasei.com (Postfix, from userid 103) id 11AEA1CDA5; Wed, 12 May 2004 21:19:26 +0100 (BST)
X-Original-To: group-post+cdbi-talk [...] soto.kasei.com
Received: by soto.kasei.com (Postfix, from userid 107) id BC8CC1CD8B; Wed, 12 May 2004 21:19:20 +0100 (BST)
Received: from host01.diablo.sk (virtual.diablo.sk [193.111.96.2]) by soto.kasei.com (Postfix) with ESMTP id 52C761CC74 for <cdbi-talk [...] groups.kasei.com>; Wed, 12 May 2004 21:19:19 +0100 (BST)
Received: from blueorange.sk (main.dobi.sk [62.168.101.254]) by host01.diablo.sk (Postfix) with ESMTP id 4703D189 for <cdbi-talk [...] groups.kasei.com>; Wed, 12 May 2004 22:19:18 +0200 (CEST)
Message-ID: <40A286C3.2060009 [...] blueorange.sk>
Date: Wed, 12 May 2004 22:19:15 +0200
From: Branislav Zahradnik <brano [...] blueorange.sk>
Reply-To: brano [...] blueorange.sk
Organization: blueorange s.r.o
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7b) Gecko/20040316
X-Accept-Language: en-us, en
MIME-Version: 1.0
To: cdbi-talk [...] groups.kasei.com
Subject: find_or_create enhancement
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
X-Virus-Scanned: by amavisd at mx1.diablo.sk
X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.10
X-Loop: cdbi-talk [...] groups.kasei.com
X-Sequence: 4068
Errors-To: cdbi-talk-owner [...] groups.kasei.com
Precedence: list
X-No-Archive: yes
List-ID: <cdbi-talk.groups.kasei.com>
List-Help: <mailto:sympa [...] groups.kasei.com?subject=help>
List-Subscribe: <mailto:sympa [...] groups.kasei.com?subject=subscribe%20cdbi-talk>
List-Unsubscribe: <mailto:sympa [...] groups.kasei.com?subject=unsubscribe%20cdbi-talk>
List-Post: <mailto:cdbi-talk [...] groups.kasei.com>
List-Owner: <mailto:cdbi-talk-request [...] groups.kasei.com>
List-Archive: <http://groups.kasei.com/mail/arc/cdbi-talk>
X-RT-Original-Encoding: us-ascii
Content-Length: 495
Download (untitled) / with headers
text/plain 495b
hi, there is small enhancement of find_or_create method. it allows to specify some "default" values for created object. Class->find_or_create (name => 'Name', surnname => 'Surname', {default => 1}); sub find_or_create { my $class = shift; my $default = ref $_[$#_] eq "HASH" && $#_ > 0 ? pop : {}; my $hash = ref $_[0] eq "HASH" ? shift: {@_}; my ($exists) = $class->search($hash); return defined($exists) ? $exists : $class->create({%$hash, %$default}); }
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: binary
MIME-Version: 1.0
X-Mailer: MIME-tools 5.415 (Entity 5.415)
X-RT-Original-Encoding: iso-8859-1
Content-Length: 765
Download (untitled) / with headers
text/plain 765b
Show quoted text
> there is small enhancement of find_or_create method. > it allows to specify some "default" values for created object. > Class->find_or_create > (name => 'Name', surnname => 'Surname', {default => 1}); > sub find_or_create { > my $class = shift; > my $default = ref $_[$#_] eq "HASH" && $#_ > 0 ? pop : {}; > my $hash = ref $_[0] eq "HASH" ? shift: {@_}; > my ($exists) = $class->search($hash); > return defined($exists) ? $exists : $class->create({%$hash, > %$default}); > }
Hi, Thanks for this, but I don't understand it. In the code it looks like $default is a hashref, but in your example it looks like it's a boolean. If you were to put together a test case (and ideally some docs) as well, it might help. Thanks, Tony


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.