2007-01-11から1日間の記事一覧

Class::DBI

HASHのリファでもよかったのね。 oooo orz sub find_or_create { my $class = shift; my $hash = ref $_[0] eq "HASH" ? shift: {@_}; my ($exists) = $class->search($hash); return defined($exists) ? $exists : $class->insert($hash); } http://search.…

DBIC ResultSetManager

こういうふうにメソッドはやしたいなら $hoge->('Artist')->hoge; こうすれば良かったのね。 package Hoge::Schema::Artist; use base qw/DBIx::Class/; __PACKAGE__->load_components(qw/ResultSetManager PK::Auto Core/); sub hoge : ResultSet { my $sel…

Catalyst Plugin

事前処理を追加したい場合、こんな感じになるわけね。 sub prepare { my $c = shift; $c = $c->NEXT::prepare(@_); # 処理 return $c; } 参考http://search.cpan.org/~lyokato/Catalyst-Plugin-FormValidator-Simple-0.12/lib/Catalyst/Plugin/FormValidator…