sub begin :Private
{
- $DB::single = 1;
my ($self, $c) = @_;
Catalyst::Controller::DBIC::API::Request->meta->apply($c->req)
sub setup :Chained('specify.in.subclass.config') :CaptureArgs(0) :PathPart('specify.in.subclass.config')
{
- $DB::single = 1;
my ($self, $c) = @_;
$c->req->_set_current_result_set($self->stored_result_source->resultset);
sub deserialize :ActionClass('Deserialize')
{
- $DB::single = 1;
my ($self, $c) = @_;
my $req_params;
sub inflate_request
{
- $DB::single = 1;
my ($self, $c, $params) = @_;
try
sub list :Private
{
- $DB::single = 1;
my ($self, $c) = @_;
$self->list_munge_parameters($c);
sub list_perform_search
{
- $DB::single = 1;
my ($self, $c) = @_;
try
sub list_format_output
{
- $DB::single = 1;
my ($self, $c) = @_;
my $rs = $c->req->current_result_set->search;
foreach my $row ($rs->all)
{
- push(@$formatted, $self->row_format_output($row));
+ push(@$formatted, $self->row_format_output($c, $row));
}
$output->{$self->data_root} = $formatted;
=method_protected row_format_output
-row_format_output is called each row of the inflated output generated from the search. It receives only one argument, the hashref that represents the row. By default, this method is merely a passthrough.
+row_format_output is called each row of the inflated output generated from the search. It receives two arguments, the catalyst context and the hashref that represents the row. By default, this method is merely a passthrough.
=cut
-sub row_format_output { shift; shift; } # passthrough by default
+sub row_format_output
+{
+ my ($self, $c, $row) = @_;
+ return $row; # passthrough by default
+}
=method_protected update_or_create
sub update_or_create :Private
{
- $DB::single = 1;
my ($self, $c) = @_;
if($c->req->has_objects)
{
$self->validate_objects($c);
- $self->transact_objects($c, sub { $self->save_objects(@_) } );
+ $self->transact_objects($c, sub { $self->save_objects($c, @_) } );
}
else
{
sub transact_objects
{
- $DB::single = 1;
my ($self, $c, $coderef) = @_;
try
sub validate_objects
{
- $DB::single = 1;
my ($self, $c) = @_;
try
sub validate_object
{
- $DB::single = 1;
my ($self, $c, $obj) = @_;
my ($object, $params) = @$obj;
sub delete :Private
{
- $DB::single = 1;
my ($self, $c) = @_;
if($c->req->has_objects)
{
- $self->transact_objects($c, sub { $self->delete_objects(@_) });
+ $self->transact_objects($c, sub { $self->delete_objects($c, @_) });
$c->req->clear_objects;
}
else
sub save_objects
{
- my ($self, $objects) = @_;
+ my ($self, $c, $objects) = @_;
foreach my $obj (@$objects)
{
- $self->save_object($obj);
+ $self->save_object($c, $obj);
}
}
sub save_object
{
- my ($self, $obj) = @_;
+ my ($self, $c, $obj) = @_;
my ($object, $params) = @$obj;
if ($object->in_storage)
{
- $self->update_object_from_params($object, $params);
+ $self->update_object_from_params($c, $object, $params);
}
else
{
- $self->insert_object_from_params($object, $params);
+ $self->insert_object_from_params($c, $object, $params);
}
}
sub update_object_from_params
{
- my ($self, $object, $params) = @_;
+ my ($self, $c, $object, $params) = @_;
foreach my $key (keys %$params)
{
my $value = $params->{$key};
if (ref($value) && !($value == JSON::Any::true || $value == JSON::Any::false))
{
- $self->update_object_relation($object, delete $params->{$key}, $key);
+ $self->update_object_relation($c, $object, delete $params->{$key}, $key);
}
}
sub update_object_relation
{
- my ($self, $object, $related_params, $relation) = @_;
+ my ($self, $c, $object, $related_params, $relation) = @_;
my $row = $object->find_related($relation, {} , {});
$row->update($related_params);
}
sub insert_object_from_params
{
- my ($self, $object, $params) = @_;
+ my ($self, $c, $object, $params) = @_;
$object->set_columns($params);
$object->insert;
}
sub delete_objects
{
- my ($self, $objects) = @_;
+ my ($self, $c, $objects) = @_;
- map { $self->delete_object($_->[0]) } @$objects;
+ map { $self->delete_object($c, $_->[0]) } @$objects;
}
=method_protected delete_object
sub delete_object
{
- my ($self, $object) = @_;
+ my ($self, $c, $object) = @_;
$object->delete;
}
sub end :Private
{
- $DB::single = 1;
my ($self, $c) = @_;
# check for errors
}
elsif($self->return_object && $c->req->has_objects)
{
- $DB::single = 1;
my $returned_objects = [];
push(@$returned_objects, $self->each_object_inflate($c, $_)) for map { $_->[0] } $c->req->all_objects;
$c->stash->{response}->{$self->data_root} = scalar(@$returned_objects) > 1 ? $returned_objects : $returned_objects->[0];