NAME

Simo::Wrapper - Wrapper class to manipulate object.

VERSION

Version 0.0214

CAUTION

Simo::Wrapper is yet experimental stage.

Please wait until Simo::Wrapper will be stable.

SYNOPSIS

use Simo::Util 'o';
# new
my $book = o('Book')->new( title => 'Good day', price => 1000 );

# connect
my $dbh = o('DBI')->connect( 'dbi:SQLite:db_name=test_db', '', '' );

# new_and_validate
my $book = o('Book')->new_and_validate(
    title => 'a', sub{ length $_ < 30 },
    price => 1000, sub{ $_ > 0 && $_ < 50000 },
);

my $book = o('Book')->new_and_validate(
    { title => 'a', price => 'b' },
    { title=> sub{ length $_ < 30 }, price => sub{ $_ > 0 && $_ < 50000 } }
);

# set_values
o($book)->set_values( title => 'Good news', author => 'kimoto' );

# get_values
my ( $title, $author ) = o($book)->get_values( qw/ title author / );

# get_hashs
my $hash = o($book)->get_hash( qw/ title author / );

# run_method
o($book_list)->run_methods(
    find => [ 'author' => 'kimoto' ],
    sort => [ 'price', 'desc' ],
    'get_result'
);

# filter_values
o($book)->filter_values(
    sub{ uc $_ },
    qw/ title author /,
);

# encode_values and decode_values
o($book)->encode_values( 'utf8', qw/ title author / );
o($book)->decode_values( 'utf8', qw/ title author / );

# clone
my $book_copy = o($book)->clone;

# freeze and thaw
my $book_freezed = o($book)->freeze;
my $book = o->thaw( $book_freezed );

# new_from_xml and set_values_from_xml
my $book = o->new_from_xml( $xml_file );
o($book)->set_values_from_xml( $xml_file );

FEATURES

Simo::Wrapper is the collection of methods to manipulate a object.

To use a class not calling 'require', use 'new'. 'new' automatically load the class, and call 'new' method.

To create a object and validate values, use 'new_and_validate'.

To set or get multiple values, use 'set_values', 'get_value', 'get_hash'.

To call multiple methods, use 'run_methods'.

To convert values to other value, use 'filter_values'.

To encode or decode values, use 'encode_values' or 'decode_values'.

To clone or freeze or thaw the object, use 'clone', 'freeze' or 'thaw'.

To create a object form xml file, use 'new_from_xml'.

To set values using xml file, use 'set_values_from_xml'.

Simo::Wrapper is designed to be used from Simo::Util o function. See also Simo::Util

FUNCTION

Simo::Wrapper object is usually used from Simo::Util o function, so sample is explain using this function.

new

'new' is a object constructor. Unlike normal 'new', this 'new' load class automatically and construct object.

my $book = o('Book')->new( title => 'Good day', price => 1000 );

You no longer call 'require' or 'use'.

connect

'connect' is the same as 'new'.

I prepare 'connect' method because classes like 'DBI' has 'connect' method as the object constructor.

my $dbh = o('DBI')->connect( 'dbi:SQLite:db_name=test_db', '', '' );

obj =head2 create =head2 build =head2 validate =head2 new_and_validate =head2 new_from_objective_hash =head2 new_from_xml =head2 get_values =head2 get_hash =head2 set_values =head2 set_values_from_objective_hash =head2 set_values_from_xml =head2 run_methods =head2 _parse_run_methods_args =head2 filter_values =head2 encode_values =head2 decode_values =head2 clone =head2 freeze =head2 thaw

AUTHOR

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

BUGS

Please report any bugs or feature requests to bug-simo-wrapper at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Simo-Wrapper. 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::Wrapper

You can also look for information at:

ACKNOWLEDGEMENTS

COPYRIGHT & LICENSE

Copyright 2009 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.