{
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;
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(@_) }