Skip to content

Commit

Permalink
there is no need for a public can_roles method, since Role::Tiny is r…
Browse files Browse the repository at this point in the history
…equired by every role anyway
  • Loading branch information
kraih committed Aug 11, 2017
1 parent 5e46ffa commit 6a745ca
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 17 deletions.
4 changes: 2 additions & 2 deletions Changes
@@ -1,8 +1,8 @@

7.40 2017-08-10
7.40 2017-08-11
- Added support for Role::Tiny extensions to all classes based on Mojo::Base.
(dotan)
- Added can_roles and with_roles methods to Mojo::Base. (dotan)
- Added with_roles method to Mojo::Base. (dotan)

7.39 2017-08-03
- Removed experimental close_idle_connections method from
Expand Down
16 changes: 4 additions & 12 deletions lib/Mojo/Base.pm
Expand Up @@ -65,8 +65,6 @@ sub attr {
}
}

sub can_roles {ROLES}

sub import {
my $class = shift;
return unless my $flag = shift;
Expand Down Expand Up @@ -221,13 +219,6 @@ executed at accessor read time if there's no set value, and gets passed the
current instance of the object as first argument. Accessors can be chained, that
means they return their invocant when they are called with an argument.
=head2 can_roles
my $bool = Mojo::Base->can_roles;
True if L<Role::Tiny> 2.000001+ is installed and roles are supported in
L<Mojo::Base> derived classes.
=head2 new
my $object = SubClass->new;
Expand Down Expand Up @@ -260,10 +251,11 @@ spliced or tapped into) a chained set of object method calls.
my $new_class = SubClass->with_roles('Foo::Role1', 'Bar::Role2');
Create and return a new class that extends the given class with the list of
roles using L<Role::Tiny>.
Create and return a new class that extends the given class with one or more
L<Role::Tiny> roles. Note that role support depends on L<Role::Tiny>
(2.000001+).
# Create a new class and instantiate it
# Create a new class with roles and instantiate it
my $new_class = SubClass->with_roles('Foo::Role1', 'Foo::Role2');
my $object = $new_class->new;
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojolicious/Command/version.pm
Expand Up @@ -11,12 +11,12 @@ has usage => sub { shift->extract_usage };
sub run {
my $self = shift;

my $ev = eval 'use Mojo::Reactor::EV; 1' ? $EV::VERSION : 'n/a';
my $ev = eval { require Mojo::Reactor::EV; 1 } ? $EV::VERSION : 'n/a';
my $socks
= Mojo::IOLoop::Client->can_socks ? $IO::Socket::Socks::VERSION : 'n/a';
my $tls = Mojo::IOLoop::TLS->can_tls ? $IO::Socket::SSL::VERSION : 'n/a';
my $nnr = Mojo::IOLoop::Client->can_nnr ? $Net::DNS::Native::VERSION : 'n/a';
my $roles = Mojo::Base->can_roles ? $Role::Tiny::VERSION : 'n/a';
my $roles = Mojo::Base->ROLES ? $Role::Tiny::VERSION : 'n/a';

print <<EOF;
CORE
Expand Down
2 changes: 1 addition & 1 deletion t/mojo/base_roles.t
Expand Up @@ -4,7 +4,7 @@ use Test::More;

BEGIN {
plan skip_all => 'Role::Tiny 2.000001+ required for this test!'
unless Mojo::Base->can_roles;
unless Mojo::Base->ROLES;
}

package Mojo::RoleTest::LOUD;
Expand Down

0 comments on commit 6a745ca

Please sign in to comment.