The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Simo - Very simple framework for Object Oriented Perl.

VERSION

Version 0.1001

CAUTION

Simo is yet experimenta stage.

Please wait until Simo will be stable.

FEATURES

Simo is framework that simplify Object Oriented Perl.

The feature is that

1. You can define accessors in very simple way.
2. new method is prepared.
3. You can define default value of attribute.
4. Error object is thrown, when error is occured.

If you use Simo, you are free from bitter work writing new methods and accessors repeatedly.

SYNOPSIS

Class definition

    package Book;
    use Simo;
    
    sub title{ ac }
    sub author{ ac }
    sub price{ ac }

Using class

    use Book;
    my $book = Book->new( title => 'a', author => 'b', price => 1000 );
    

Default value of attribute

    sub author{ ac default => 'Kimoto' }

Constraint of attribute setting

    use Simo::Constrain qw( is_int isa );
    sub price{ ac constrain => sub{ is_int } }
    sub author{ ac constrain => sub{ isa 'Person' } }

Filter of attribute setting

    sub author{ ac filter => sub{ uc } }

Trigger of attribute setting

    sub date{ ac trigger => sub{ $_->year( substr( $_->date, 0, 4 ) ) } } 
    sub year{ ac }

Read only accessor

    sub year{ ac read_only => 1 }

Hash ref convert of attribute setting

    sub country_id{ ac hash_force => 1 }

Required attributes

    sub REQUIRED_ATTRS{ qw( title author ) }

Inheritance

    package Magazine;
    use Simo( base => 'Book' );

Mixin

    package Book;
    use Simo( mixin => 'Class::Cloneable' );

Manual

See Simo::Manual.

I explain detail of Simo.

If you are Japanese, See also Simo::Manual::Japanese.

FUNCTIONS

ac

ac is exported. This is used to define accessor.

    package Book;
    use Simo;
    
    sub title{ ac }
    sub author{ ac }
    sub price{ ac }

and_super

and_super is exported. This is used to call super method for REQUIRED_ATTRS.

    sub REQUIRED_ATTRS{ 'm1', 'm2', and_super }

METHODS

new

new method is prepared.

    use Book;
    my $book = Book->new( title => 'a', author => 'b', price => 1000 );

new_self_and_parent

new_self_and_parent resolve the inheritance of no Simo based class;

    $self->new_self_and_parent( @_, [ 'title', 'author' ] );
    
    $self->new_self_and_parent( { self_args => [], parent_args => [] } );

REQUIRED_ATTRS

this method is expected to override.

You can define required attribute.

    package Book;
    use Simo;
    
    sub title{ ac }
    sub author{ ac }
    sub price{ ac }
    
    sub REQUIRED_ATTRS{ qw( title author ) }

SEE ALSO

Simo::Constrain - Constraint methods for Simo 'constrain' option.

Simo::Error - Structured error system for Simo.

Simo::Util - Utitlity class for Simo.

Simo::Wrapper - provide useful methods for object.

CAUTION

set_hook and get_hook option is now not recommended. These option will be removed in future 2019/01/01

non named defalut value definition is now not recommended. This expression will be removed in future 2019/01/01

    sub title{ ac 'OO tutorial' } # not recommend. cannot be available in future.

get_attrs,get_attrs_as_hash,set_attrs,run_methods is now not recommended. These methods will be removed in future 2019/01/01

AUTHOR

Yuki Kimoto, <kimoto.yuki at gmail.com>

BUGS

Please report any bugs or feature requests to bug-simo at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Simo. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Simo

You can also look for information at:

SIMILAR MODULES

Class::Accessor,Class::Accessor::Fast, Moose, Mouse.

COPYRIGHT & LICENSE

Copyright 2008 Yuki Kimoto, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.