Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
removed perl method again
  • Loading branch information
kraih committed Aug 17, 2012
1 parent d26a9d8 commit b01071c
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 35 deletions.
4 changes: 2 additions & 2 deletions Changes
@@ -1,8 +1,8 @@

3.32 2012-08-17
3.32 2012-08-18
- Added event sequentialization support to Mojo::IOLoop::Delay.
(judofyr, marcus, sri)
- Added perl and tap methods to Mojo::Base.
- Added tap method to Mojo::Base.
- Added squish method to Mojo::ByteStream.
- Added squish function to Mojo::Util.
- Improved documentation.
Expand Down
15 changes: 3 additions & 12 deletions lib/Mojo/Base.pm
Expand Up @@ -7,8 +7,7 @@ use warnings;
use feature ();

# No imports because we get subclassed, a lot!
use Carp ();
use Data::Dumper ();
use Carp ();

# Only Perl 5.14+ requires it on demand
use IO::Handle ();
Expand Down Expand Up @@ -101,8 +100,6 @@ sub attr {
}
}

sub perl { Data::Dumper->new([@_])->Indent(1)->Terse(1)->Dump }

sub tap {
my ($self, $cb) = @_;
$_->$cb for $self;
Expand Down Expand Up @@ -134,10 +131,10 @@ Mojo::Base - Minimal base class for Mojo projects
my $mew = Cat->new(name => 'Longcat');
say $mew->paws;
say $mew->paws(5)->ears(4)->perl;
say $mew->paws(5)->ears(4)->paws;
my $rawr = Tiger->new(stripes => 23);
say $rawr->tap(sub { $_->friend->name('Tacgnol') })->perl;
say $rawr->tap(sub { $_->friend->name('Tacgnol') })->paws;
=head1 DESCRIPTION
Expand Down Expand Up @@ -219,12 +216,6 @@ attribute. Pass an optional second argument to set a default value, it should
be a constant or a sub reference. The sub reference will be excuted at
accessor read time if there's no set value.
=head2 C<perl>
my $string = $object->perl;
Dump object with L<Data::Dumper>.
=head2 C<tap>
$object = $object->tap(sub {...});
Expand Down
6 changes: 2 additions & 4 deletions lib/Mojo/ByteStream.pm
@@ -1,8 +1,7 @@
package Mojo::ByteStream;
use Mojo::Base -base;
use Mojo::Base 'Exporter';
use overload '""' => sub { shift->to_string }, fallback => 1;

use Exporter 'import';
use Mojo::Collection;
use Mojo::Util;

Expand Down Expand Up @@ -118,8 +117,7 @@ Construct a new L<Mojo::ByteStream> object.
=head1 METHODS
L<Mojo::ByteStream> inherits all methods from L<Mojo::Base> and implements the
following new ones.
L<Mojo::ByteStream> implements the following methods.
=head2 C<new>
Expand Down
6 changes: 2 additions & 4 deletions lib/Mojo/Collection.pm
@@ -1,11 +1,10 @@
package Mojo::Collection;
use Mojo::Base -base;
use Mojo::Base 'Exporter';
use overload
'bool' => sub {1},
'""' => sub { shift->join("\n") },
fallback => 1;

use Exporter 'import';
use List::Util;
use Mojo::ByteStream;

Expand Down Expand Up @@ -121,8 +120,7 @@ Construct a new L<Mojo::Collection> object.
=head1 METHODS
L<Mojo::Collection> inherits all methods from L<Mojo::Base> and implements the
following new ones.
L<Mojo::Collection> implements the following methods.
=head2 C<new>
Expand Down
6 changes: 2 additions & 4 deletions lib/Mojo/DOM.pm
@@ -1,13 +1,12 @@
package Mojo::DOM;
use Mojo::Base -base;
use Mojo::Base -strict;
use overload
'%{}' => sub { shift->attrs },
'bool' => sub {1},
'""' => sub { shift->to_xml },
fallback => 1;

use Carp 'croak';
use Exporter 'import';
use Mojo::Collection;
use Mojo::DOM::CSS;
use Mojo::DOM::HTML;
Expand Down Expand Up @@ -460,8 +459,7 @@ XML detection can also be disabled with the C<xml> method.
=head1 METHODS
L<Mojo::DOM> inherits all methods from L<Mojo::Base> and implements the
following new ones.
L<Mojo::DOM> implements the following methods.
=head2 C<new>
Expand Down
6 changes: 5 additions & 1 deletion lib/Mojolicious/Plugin/DefaultHelpers.pm
@@ -1,6 +1,8 @@
package Mojolicious::Plugin::DefaultHelpers;
use Mojo::Base 'Mojolicious::Plugin';

use Data::Dumper ();

# "You're watching Futurama,
# the show that doesn't condone the cool crime of robbery."
sub register {
Expand Down Expand Up @@ -37,7 +39,7 @@ sub register {
$app->helper(current_route => \&_current_route);

# Add "dumper" helper
$app->helper(dumper => sub { shift; Mojo::Base::perl(@_) });
$app->helper(dumper => \&_dumper);

# Add "include" helper
$app->helper(include => \&_include);
Expand Down Expand Up @@ -83,6 +85,8 @@ sub _current_route {
return $endpoint->name eq shift;
}

sub _dumper { shift; Data::Dumper->new([@_])->Indent(1)->Terse(1)->Dump }

sub _include {
my $self = shift;
my $template = @_ % 2 ? shift : undef;
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojolicious/Routes.pm
Expand Up @@ -11,7 +11,7 @@ use Scalar::Util 'weaken';
has base_classes => sub { [qw(Mojolicious::Controller Mojo)] };
has cache => sub { Mojo::Cache->new };
has [qw(conditions shortcuts)] => sub { {} };
has hidden => sub { [qw(attr has new perl tap)] };
has hidden => sub { [qw(attr has new tap)] };
has 'namespace';

sub add_condition {
Expand Down Expand Up @@ -300,7 +300,7 @@ Contains all available conditions.
$r = $r->hidden([qw(attr has new)]);
Controller methods and attributes that are hidden from routes, defaults to
C<attr>, C<has>, C<new>, C<perl> and C<tap>.
C<attr>, C<has>, C<new> and C<tap>.
=head2 C<namespace>
Expand Down
7 changes: 1 addition & 6 deletions t/mojo/base.t
@@ -1,6 +1,6 @@
use Mojo::Base -strict;

use Test::More tests => 416;
use Test::More tests => 415;

use FindBin;
use lib "$FindBin::Bin/lib";
Expand Down Expand Up @@ -87,11 +87,6 @@ is $monkey->tap(sub { $_->name('foo') })->name, 'foo', 'right attribute value';
is $monkey->tap(sub { shift->name('bar')->name })->name, 'bar',
'right attribute value';

# Dump object
$monkey = BaseTest->new(name => 'foo');
is $monkey->perl, "bless( {\n 'name' => 'foo'\n}, 'BaseTest' )\n",
'right result';

# Inherit -base flag
$monkey = BaseTest::Base3->new(evil => 1);
is $monkey->evil, 1, 'monkey is evil';
Expand Down

0 comments on commit b01071c

Please sign in to comment.