Navigation Menu

Skip to content

Commit

Permalink
document overloaded operators in separate section
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jan 22, 2014
1 parent 130f717 commit 86dcdd0
Show file tree
Hide file tree
Showing 11 changed files with 194 additions and 24 deletions.
17 changes: 16 additions & 1 deletion lib/Mojo/ByteStream.pm
Expand Up @@ -286,7 +286,6 @@ Alias for L<Mojo::Base/"tap">.
=head2 to_string
my $str = $stream->to_string;
my $str = "$stream";
Stringify bytestream.
Expand Down Expand Up @@ -335,6 +334,22 @@ bytestream with L<Mojo::Util/"xml_escape">.
XOR encode bytestream with L<Mojo::Util/"xor_encode">.
=head1 OPERATORS
L<Mojo::ByteStream> overloads the following operators.
=head2 bool
my $bool = !!$bytestream;
Always true.
=head2 stringify
my $str = "$bytestream";
Alias for L</to_string>.
=head1 BYTESTREAM
Direct scalar reference access to the bytestream is also possible.
Expand Down
16 changes: 16 additions & 0 deletions lib/Mojo/Collection.pm
Expand Up @@ -282,6 +282,22 @@ Alias for L<Mojo::Base/"tap">.
Create a new collection without duplicate elements.
=head1 OPERATORS
L<Mojo::Collection> overloads the following operators.
=head2 bool
my $bool = !!$collection;
Always true.
=head2 stringify
my $str = "$collection";
Stringify elements in collection and L</"join"> them with newlines.
=head1 ELEMENT METHODS
In addition to the methods above, you can also call methods provided by all
Expand Down
17 changes: 16 additions & 1 deletion lib/Mojo/Cookie.pm
Expand Up @@ -62,10 +62,25 @@ Parse cookies. Meant to be overloaded in a subclass.
=head2 to_string
my $str = $cookie->to_string;
my $str = "$cookie";
Render cookie. Meant to be overloaded in a subclass.
=head1 OPERATORS
L<Mojo::Cookie> overloads the following operators.
=head2 bool
my $bool = !!$cookie;
Always true.
=head2 stringify
my $str = "$cookie";
Alias for L</to_string>.
=head1 SEE ALSO
L<Mojolicious>, L<Mojolicious::Guides>, L<http://mojolicio.us>.
Expand Down
33 changes: 25 additions & 8 deletions lib/Mojo/DOM.pm
Expand Up @@ -757,7 +757,6 @@ is enabled by default.
=head2 to_xml
my $xml = $dom->to_xml;
my $xml = "$dom";
Render this element and its content to XML.
Expand Down Expand Up @@ -790,6 +789,31 @@ Element type.
Disable HTML semantics in parser and activate case sensitivity, defaults to
auto detection based on processing instructions.
=head1 OPERATORS
L<Mojo::DOM> overloads the following operators.
=head2 bool
my $bool = !!$dom;
Always true.
=head2 hash
my %attrs = %$dom;
Alias for L</"attr">.
say $dom->{foo};
say $dom->div->{id};
=head2 stringify
my $xml = "$dom";
Alias for L</"to_xml">.
=head1 CHILD ELEMENTS
In addition to the methods above, many child elements are also automatically
Expand All @@ -800,13 +824,6 @@ L<Mojo::Collection> object, depending on number of children.
say $dom->div->[23]->text;
say $dom->div->text;
=head1 ELEMENT ATTRIBUTES
Direct hash reference access to element attributes is also possible.
say $dom->{foo};
say $dom->div->{id};
=head1 SEE ALSO
L<Mojolicious>, L<Mojolicious::Guides>, L<http://mojolicio.us>.
Expand Down
17 changes: 16 additions & 1 deletion lib/Mojo/DOM/Node.pm
Expand Up @@ -72,7 +72,6 @@ following new ones.
my $content = $node->content;
$node = $node->content('foo');
my $content = "$node";
Node content.
Expand All @@ -88,6 +87,22 @@ Node type, usually C<cdata>, C<comment>, C<doctype>, C<pi>, C<raw> or C<text>.
Remove node and return L<Mojo::DOM> object for parent of node.
=head1 OPERATORS
L<Mojo::DOM::Node> overloads the following operators.
=head2 bool
my $bool = !!$node;
Always true.
=head2 stringify
my $content = "$node";
Alias for L</content>.
=head1 SEE ALSO
L<Mojolicious>, L<Mojolicious::Guides>, L<http://mojolicio.us>.
Expand Down
17 changes: 16 additions & 1 deletion lib/Mojo/Date.pm
Expand Up @@ -128,10 +128,25 @@ Parse date.
=head2 to_string
my $str = $date->to_string;
my $str = "$date";
Render date suitable for HTTP messages.
=head1 OPERATORS
L<Mojo::Date> overloads the following operators.
=head2 bool
my $bool = !!$date;
Always true.
=head2 stringify
my $str = "$date";
Alias for L</to_string>.
=head1 SEE ALSO
L<Mojolicious>, L<Mojolicious::Guides>, L<http://mojolicio.us>.
Expand Down
17 changes: 16 additions & 1 deletion lib/Mojo/Exception.pm
Expand Up @@ -189,7 +189,6 @@ Throw exception with stacktrace.
=head2 to_string
my $str = $e->to_string;
my $str = "$e";
Render exception.
Expand All @@ -200,6 +199,22 @@ Render exception.
Store stacktrace.
=head1 OPERATORS
L<Mojo::Exception> overloads the following operators.
=head2 bool
my $bool = !!$e;
Always true.
=head2 stringify
my $str = "$e";
Alias for L</to_string>.
=head1 SEE ALSO
L<Mojolicious>, L<Mojolicious::Guides>, L<http://mojolicio.us>.
Expand Down
17 changes: 16 additions & 1 deletion lib/Mojo/Home.pm
Expand Up @@ -171,10 +171,25 @@ Portably generate an absolute path for a file relative to the home directory.
=head2 to_string
my $str = $home->to_string;
my $str = "$home";
Home directory.
=head1 OPERATORS
L<Mojo::Home> overloads the following operators.
=head2 bool
my $bool = !!$home;
Always true.
=head2 stringify
my $str = "$home";
Alias for L</to_string>.
=head1 SEE ALSO
L<Mojolicious>, L<Mojolicious::Guides>, L<http://mojolicio.us>.
Expand Down
24 changes: 20 additions & 4 deletions lib/Mojo/Parameters.pm
Expand Up @@ -312,18 +312,34 @@ the parameters.
=head2 to_string
my $str = $params->to_string;
my $str = "$params";
Turn parameters into a string.
=head1 PARAMETERS
=head1 OPERATORS
L<Mojo::Parameters> overloads the following operators.
=head2 array
Direct array reference access to the parsed parameters is also possible. Note
that this will normalize the parameters.
my @params = @$params;
Alias for L</"params">. Note that this will normalize the parameters.
say $params->[0];
say for @$params;
=head2 bool
my $bool = !!$params;
Always true.
=head2 stringify
my $str = "$params";
Alias for L</"to_string">.
=head1 SEE ALSO
L<Mojolicious>, L<Mojolicious::Guides>, L<http://mojolicio.us>.
Expand Down
26 changes: 21 additions & 5 deletions lib/Mojo/Path.pm
Expand Up @@ -292,7 +292,6 @@ Turn path into a route.
=head2 to_string
my $str = $path->to_string;
my $str = "$path";
Turn path into a string.
Expand All @@ -310,15 +309,32 @@ Turn path into a string.
Path has a trailing slash. Note that this method will normalize the path and
that C<%2F> will be treated as C</> for security reasons.
=head1 PATH PARTS
=head1 OPERATORS
L<Mojo::Path> overloads the following operators.
=head2 array
Direct array reference access to path parts is also possible. Note that this
will normalize the path and that C<%2F> will be treated as C</> for security
reasons.
my @parts = @$path;
Alias for L</"parts">. Note that this will normalize the path and that C<%2F>
will be treated as C</> for security reasons.
say $path->[0];
say for @$path;
=head2 bool
my $bool = !!$path;
Always true.
=head2 stringify
my $str = "$path";
Alias for L</"to_string">.
=head1 SEE ALSO
L<Mojolicious>, L<Mojolicious::Guides>, L<http://mojolicio.us>.
Expand Down
17 changes: 16 additions & 1 deletion lib/Mojo/URL.pm
Expand Up @@ -435,10 +435,25 @@ provided base URL.
=head2 to_string
my $str = $url->to_string;
my $str = "$url";
Turn URL into a string.
=head1 OPERATORS
L<Mojo::URL> overloads the following operators.
=head2 bool
my $bool = !!$url;
Always true.
=head2 stringify
my $str = "$url";
Alias for L</to_string>.
=head1 SEE ALSO
L<Mojolicious>, L<Mojolicious::Guides>, L<http://mojolicio.us>.
Expand Down

0 comments on commit 86dcdd0

Please sign in to comment.