Skip to content

Instantly share code, notes, and snippets.

@wki
Created April 25, 2012 19:23
Show Gist options
  • Save wki/2492517 to your computer and use it in GitHub Desktop.
Save wki/2492517 to your computer and use it in GitHub Desktop.
DBIx::Class manipulating result source
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