Skip to content

Please add chaining mutators #135

Open
@leonerd

Description

@leonerd

It's a common form to want to return a newly-constructed object with all the values set into it already, by having mutator methods that return the invocant, so you can easily add more. In such a style you could write:

return HTTP::Response->new( 200 )
    ->set_content_type( "text/plain" )
    ->set_content( "Hello, world" );

As it currently stands, the existing mutator methods like ->header, ->content, etc.. do not return the invocant, thus such a style is impossible and one must use a temporary:

my $resp = HTTP::Response->new( 200 );
$resp->content_type( "text/plain" );
$resp->content( "Hello, world" );
return $resp;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions