2010/3/29 Konstantin A. Pustovalov <[email protected]>:
> On 03/26/2010 07:20 PM, Oleg Kostyuk wrote:
>>
>> IIRC, evaluating ResultSet in scalar contex will issue count() call.
>>
>
> ResultSet is a blessed reference which is scalar.
> Can't i say $something = $rs ?
Yes, you can. I was not fully correct here. More correct will be
next:evaluating ResultSet in _numeric_ contex will issue count() call,
see 
http://search.cpan.org/~ribasushi/DBIx-Class-0.08120/lib/DBIx/Class/ResultSet.pm#OVERLOADING
. And so, at first comparsion with non-string, which will give you
boolean context (which in turn is one of possible numeric contexts),
you will get count() call.

I think, will be better to use something like this:

<cut>
package Test::Schema::ResultSet::User;
use strict;
use base 'DBIx::Class::ResultSet';
use Params::Validate qw/:all/;
sub touch {
  my $self = shift;
  validate_pos( ref($self), { regex => m/^__PACKAGE__$/ } );
}

1;
</cut>

Of course, this is not exactly what you wanted, because don't support
inheritance, roles and so on. Feel free to modify and implement your
own callback-validation.

--
Sincerely yours,
Oleg Kostyuk (CUB-UANIC)

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]

Reply via email to