Catalyst-Controller-DBIC-API

 view release on metacpan or  search on metacpan

lib/Catalyst/Controller/DBIC/API.pm  view on Meta::CPAN

313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
            { 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

508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
    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

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
__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

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
    $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.426 second using v1.01-cache-2.11-cpan-95122f20152 )