Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
with_roles should be available for all objects
  • Loading branch information
kraih committed Aug 15, 2017
1 parent 477514a commit a6b83c3
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 62 deletions.
2 changes: 2 additions & 0 deletions Changes
@@ -1,5 +1,7 @@

7.41 2017-08-15
- Added with_roles method to Mojo::ByteStream, Mojo::Collection, Mojo::DOM and
Mojo::File.

7.40 2017-08-14
- Added support for Role::Tiny extensions to all classes based on Mojo::Base.
Expand Down
8 changes: 8 additions & 0 deletions lib/Mojo/ByteStream.pm
Expand Up @@ -56,6 +56,8 @@ sub tap { shift->Mojo::Base::tap(@_) }

sub to_string { ${$_[0]} }

sub with_roles { shift->Mojo::Base::with_roles(@_) }

sub _delegate {
my ($self, $sub) = (shift, shift);
$$self = $sub->(shift || 'UTF-8', $$self);
Expand Down Expand Up @@ -328,6 +330,12 @@ L<Mojo::Util/"url_unescape">.
# "&lt;html&gt;"
b('%3Chtml%3E')->url_unescape->xml_escape;
=head2 with_roles
my $new_class = Mojo::ByteStream->with_roles('Foo::Role1', 'Bar::Role2');
Alias for L<Mojo::Base/"with_roles">.
=head2 xml_escape
$stream = $stream->xml_escape;
Expand Down
8 changes: 8 additions & 0 deletions lib/Mojo/Collection.pm
Expand Up @@ -99,6 +99,8 @@ sub uniq {
return $self->new(grep { !$seen{$_}++ } @$self);
}

sub with_roles { shift->Mojo::Base::with_roles(@_) }

sub _flatten {
map { _ref($_) ? _flatten(@$_) : $_ } @_;
}
Expand Down Expand Up @@ -367,6 +369,12 @@ callback/method.
# "[[1, 2], [2, 1]]"
c([1, 2], [2, 1], [3, 2])->uniq(sub{ $_->[1] })->to_array;
=head2 with_roles
my $new_class = Mojo::Collection->with_roles('Foo::Role1', 'Bar::Role2');
Alias for L<Mojo::Base/"with_roles">.
=head1 SEE ALSO
L<Mojolicious>, L<Mojolicious::Guides>, L<http://mojolicious.org>.
Expand Down
8 changes: 8 additions & 0 deletions lib/Mojo/DOM.pm
Expand Up @@ -178,6 +178,8 @@ sub val {
return exists $self->{multiple} ? $v->size ? $v->to_array : undef : $v->last;
}

sub with_roles { shift->Mojo::Base::with_roles(@_) }

sub wrap { shift->_wrap(0, @_) }
sub wrap_content { shift->_wrap(1, @_) }

Expand Down Expand Up @@ -946,6 +948,12 @@ if none could be found.
# "on"
$dom->parse('<input name=test type=checkbox>')->at('input')->val;
=head2 with_roles
my $new_class = Mojo::DOM->with_roles('Foo::Role1', 'Bar::Role2');
Alias for L<Mojo::Base/"with_roles">.
=head2 wrap
$dom = $dom->wrap('<div></div>');
Expand Down
8 changes: 8 additions & 0 deletions lib/Mojo/File.pm
Expand Up @@ -137,6 +137,8 @@ sub to_rel { $_[0]->new(abs2rel(${$_[0]}, $_[1])) }

sub to_string {"${$_[0]}"}

sub with_roles { shift->Mojo::Base::with_roles(@_) }

1;

=encoding utf8
Expand Down Expand Up @@ -446,6 +448,12 @@ L<Mojo::File> object.
Stringify the path.
=head2 with_roles
my $new_class = Mojo::File->with_roles('Foo::Role1', 'Bar::Role2');
Alias for L<Mojo::Base/"with_roles">.
=head1 OPERATORS
L<Mojo::File> overloads the following operators.
Expand Down
62 changes: 0 additions & 62 deletions t/mojo/base_roles.t

This file was deleted.

0 comments on commit a6b83c3

Please sign in to comment.