Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
made all objects a little more equal
  • Loading branch information
kraih committed Aug 17, 2012
1 parent b01071c commit 25be264
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
14 changes: 7 additions & 7 deletions lib/Mojo/Base.pm
Expand Up @@ -186,7 +186,7 @@ flag or a base class.
has [qw(name1 name2 name3)] => 'foo';
has [qw(name1 name2 name3)] => sub {...};
Create attributes, just like the C<attr> method.
Create attributes for hash-based objects, just like the C<attr> method.
=head1 METHODS
Expand All @@ -198,8 +198,8 @@ L<Mojo::Base> implements the following methods.
my $object = BaseSubClass->new(name => 'value');
my $object = BaseSubClass->new({name => 'value'});
This base class provides a basic object constructor. You can pass it either a
hash or a hash reference with attribute values.
This base class provides a basic constructor for hash-based objects. You can
pass it either a hash or a hash reference with attribute values.
=head2 C<attr>
Expand All @@ -211,10 +211,10 @@ hash or a hash reference with attribute values.
BaseSubClass->attr([qw(name1 name2 name3)] => 'foo');
BaseSubClass->attr([qw(name1 name2 name3)] => sub {...});
Create attributes. An array reference can be used to create more than one
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.
Create attributes for hash-based objects. An array reference can be used to
create more than one 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<tap>
Expand Down
8 changes: 5 additions & 3 deletions lib/Mojo/ByteStream.pm
@@ -1,7 +1,8 @@
package Mojo::ByteStream;
use Mojo::Base 'Exporter';
use Mojo::Base -base;
use overload '""' => sub { shift->to_string }, fallback => 1;

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

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

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

Expand Down Expand Up @@ -120,13 +121,14 @@ Construct a new L<Mojo::Collection> object.
=head1 METHODS
L<Mojo::Collection> implements the following methods.
L<Mojo::Collection> inherits all methods from L<Mojo::Base> and implements the
following new ones.
=head2 C<new>
my $collection = Mojo::Collection->new(1, 2, 3);
Construct a new L<Mojo::Collection> object.
Construct a new array-based L<Mojo::Collection> object.
=head2 C<each>
Expand Down
7 changes: 4 additions & 3 deletions lib/Mojo/DOM.pm
@@ -1,5 +1,5 @@
package Mojo::DOM;
use Mojo::Base -strict;
use Mojo::Base -base;
use overload
'%{}' => sub { shift->attrs },
'bool' => sub {1},
Expand Down Expand Up @@ -459,14 +459,15 @@ XML detection can also be disabled with the C<xml> method.
=head1 METHODS
L<Mojo::DOM> implements the following methods.
L<Mojo::DOM> inherits all methods from L<Mojo::Base> and implements the
following new ones.
=head2 C<new>
my $dom = Mojo::DOM->new;
my $dom = Mojo::DOM->new('<foo bar="baz">test</foo>');
Construct a new L<Mojo::DOM> object.
Construct a new array-based L<Mojo::DOM> object.
=head2 C<all_text>
Expand Down

0 comments on commit 25be264

Please sign in to comment.