Catalyst-Controller-DBIC-API
view release on metacpan or search on metacpan
lib/Catalyst/Controller/DBIC/API.pm view on Meta::CPAN
{ message => 'No objects on which to operate' } );
$c->detach();
}
else {
$c->stash->{ $self->stash_key }->{ $self->item_root } =
$self->each_object_inflate( $c, $c->req->get_object(0)->[0] );
}
}
sub update_or_create {
my ( $self, $c ) = @_;
if ( $c->req->has_objects ) {
$self->validate_objects($c);
$self->transact_objects( $c, sub { $self->save_objects( $c, @_ ) } );
}
else {
$c->log->error($_);
$self->push_error( $c,
{ message => 'No objects on which to operate' } );
lib/Catalyst/Controller/DBIC/API.pm view on Meta::CPAN
if ( $object->in_storage ) {
$self->update_object_from_params( $c, $object, $params );
}
else {
$self->insert_object_from_params( $c, $object, $params );
}
}
sub update_object_from_params {
my ( $self, $c, $object, $params ) = @_;
$params = {%$params, %{$object->ident_condition}};
my $updated_object =
DBIx::Class::ResultSet::RecursiveUpdate::Functions::recursive_update(
resultset => $c->req->current_result_set,
# unknown_params_ok => 1,
updates => $params,
);
lib/Catalyst/Controller/DBIC/API/REST.pm view on Meta::CPAN
__PACKAGE__->config(
'default' => 'application/json',
'stash_key' => 'response',
'map' => {
'application/x-www-form-urlencoded' => 'JSON',
'application/json' => 'JSON',
}
);
sub update_or_create_objects : POST PUT Chained('objects_no_id') PathPart('')
Args(0) {
my ( $self, $c ) = @_;
$self->update_or_create($c);
}
sub delete_many_objects : DELETE Chained('objects_no_id') PathPart('')
Args(0) {
my ( $self, $c ) = @_;
$self->delete($c);
}
sub list_objects : GET Chained('objects_no_id') PathPart('') Args(0) {
my ( $self, $c ) = @_;
$self->list($c);
}
sub update_or_create_one_object : POST PUT Chained('object_with_id')
PathPart('') Args(0) {
my ( $self, $c ) = @_;
$self->update_or_create($c);
}
sub delete_one_object : DELETE Chained('object_with_id') PathPart('') Args(0)
{
my ( $self, $c ) = @_;
$self->delete($c);
lib/Catalyst/Controller/DBIC/API/RPC.pm view on Meta::CPAN
$self->next::method($c);
}
sub item : Chained('object_with_id') : PathPart('') : Args(0) {
my ( $self, $c ) = @_;
$self->next::method($c);
}
sub update : Chained('object_with_id') : PathPart('update') : Args(0) {
my ( $self, $c ) = @_;
$self->update_or_create($c);
}
sub delete : Chained('object_with_id') : PathPart('delete') : Args(0) {
my ( $self, $c ) = @_;
$self->next::method($c);
}
sub update_bulk : Chained('objects_no_id') : PathPart('update') : Args(0) {
my ( $self, $c ) = @_;
$self->update_or_create($c);
}
sub delete_bulk : Chained('objects_no_id') : PathPart('delete') : Args(0) {
my ( $self, $c ) = @_;
$self->delete($c);
}
( run in 0.531 second using v1.01-cache-2.11-cpan-4d4bc49f3ae )