Created
November 7, 2012 02:42
-
-
Save moltar/4029297 to your computer and use it in GitHub Desktop.
model
This file contains hidden or 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 SW::Web::Model::DB; | |
use Moose; | |
extends 'Catalyst::Model::DBIC::Schema'; | |
use SW::Schema::RestrictingObject; | |
## CatalystX::Component::Traits | |
# has '+_trait_merge' => (default => 1); | |
__PACKAGE__->config({ | |
## Catalyst::TraitFor::Model::DBIC::Schema::PerRequestSchema | |
traits => ['PerRequestSchema'], | |
schema_class => 'SW::Schema', | |
}); | |
sub per_request_schema_attributes { | |
my ($self, $c) = @_; | |
my %params; | |
if ($c->user_exists) { | |
$params{user} = $c->user->get_object; | |
} | |
if (defined $c->stash->{company}) { | |
$params{company} = $c->stash->{company}; | |
} | |
if (%params) { | |
return ( | |
restricting_object => SW::Schema::RestrictingObject->new(%params) | |
); | |
} else { | |
return (); | |
} | |
} | |
=head1 NAME | |
SW::Web::Model::DB - Catalyst DBIC Schema Model | |
=head1 SYNOPSIS | |
... | |
=head1 DESCRIPTION | |
L<Catalyst::Model::DBIC::Schema> Model using schema L<SW::Schema> | |
=cut | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment