in reply to Moose, SQL and initialization via Moose::Meta::Attribute
I'm not sure how to do this via meta ... but isn't this kinda what the BUILD method should be used for?
package GSM::Cell; use Moose; use MooseX::AttributeHelpers; use Data::Dumper; has 'BCCH' => (is => 'rw'); has 'LAC' => (is => 'ro', required => 1); has 'CI' => (is => 'ro', required => 1); has 'NAME' => (is => 'rw', lazy => 1, default => &set_name); has 'ID' => (is => 'ro', lazy => 1, default => \&set_id); with qw(SQLConnection); ... sub BUILD { my $self = shift; my $sth = $self->dbh->prepare('select BCCHFrequency from Cell where + CI = ? and LAC = ?); $sth->execute($self->CI,$self->LAC); $self->BCCH( $sth->fetchrow_array ); } ...
|
|---|