-#!/usr/bin/perl
-
use strict;
use warnings;
-use Test::More tests => 29;
+use Test::More tests => 28;
use File::Spec;
-BEGIN {
- use_ok('Class::MOP');
- require_ok(File::Spec->catdir('examples', 'ClassEncapsulatedAttributes.pod'));
+BEGIN {use Class::MOP;
+ require_ok(File::Spec->catfile('examples', 'ClassEncapsulatedAttributes.pod'));
}
{
package Foo;
- sub meta { ClassEncapsulatedAttributes->initialize($_[0]) }
+ use metaclass 'ClassEncapsulatedAttributes';
- Foo->meta->add_attribute(
- ClassEncapsulatedAttributes::Attribute->new('foo' => (
- accessor => 'foo',
- predicate => 'has_foo',
- default => 'init in FOO'
- ))
- );
+ Foo->meta->add_attribute('foo' => (
+ accessor => 'foo',
+ predicate => 'has_foo',
+ default => 'init in FOO'
+ ));
- Foo->meta->add_attribute(
- ClassEncapsulatedAttributes::Attribute->new('bar' => (
- reader => 'get_bar',
- writer => 'set_bar',
- default => 'init in FOO'
- ))
- );
+ Foo->meta->add_attribute('bar' => (
+ reader => 'get_bar',
+ writer => 'set_bar',
+ default => 'init in FOO'
+ ));
sub new {
my $class = shift;
- bless $class->meta->construct_instance(@_) => $class;
+ $class->meta->new_object(@_);
}
package Bar;
our @ISA = ('Foo');
- Bar->meta->add_attribute(
- ClassEncapsulatedAttributes::Attribute->new('foo' => (
- accessor => 'foo',
- predicate => 'has_foo',
- default => 'init in BAR'
- ))
- );
+ Bar->meta->add_attribute('foo' => (
+ accessor => 'foo',
+ predicate => 'has_foo',
+ default => 'init in BAR'
+ ));
- Bar->meta->add_attribute(
- ClassEncapsulatedAttributes::Attribute->new('bar' => (
- reader => 'get_bar',
- writer => 'set_bar',
- default => 'init in BAR'
- ))
- );
+ Bar->meta->add_attribute('bar' => (
+ reader => 'get_bar',
+ writer => 'set_bar',
+ default => 'init in BAR'
+ ));
sub SUPER_foo { (shift)->SUPER::foo(@_) }
sub SUPER_has_foo { (shift)->SUPER::foo(@_) }