Created
April 25, 2012 19:23
-
-
Save wki/2492517 to your computer and use it in GitHub Desktop.
DBIx::Class manipulating result source
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Schema::Result::Alarm; | |
use Moose; | |
use MooseX::NonMoose; | |
use MooseX::MarkAsMethods autoclean => 1; | |
extends 'DBIx::Class::Core'; | |
__PACKAGE__->table_class('Schema::ResultSource::Alarm'); | |
__PACKAGE__->table("alarm"); | |
... | |
# must be old-school perl -- dunno why :-( | |
package Schema::ResultSource::Alarm; | |
use strict; | |
use warnings; | |
use base 'DBIx::Class::ResultSource::Table'; | |
sub set_xxx { | |
my $self = shift; | |
$self->{_xxx} = shift // 'bla_foo'; | |
} | |
sub from { | |
my $self = shift; | |
warn "FROM running..., self = $self"; | |
my $from = $self->next::method(@_); | |
return "(select *, '$self->{_xxx}' as text from $from)"; | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment