MetaStore::Item - Base class for collections.


MetaStore documentation Contained in the MetaStore distribution.

Index


Code Index:

NAME

Top

MetaStore::Item - Base class for collections.

SYNOPSIS

Top

    use MetaStore::Item;
    use base qw( MetaStore::Item );




DESCRIPTION

Top

Base class for collections.

METHODS

Top

dump

Dump object state

restore (<data ref>)

Restore state

attr

Get intem attributes

id

Get id of object

SEE ALSO

Top

MetaStore, Collection::Item, README

AUTHOR

Top

Zahatski Aliaksandr, <zag@cpan.org>

COPYRIGHT AND LICENSE

Top


MetaStore documentation Contained in the MetaStore distribution.
package MetaStore::Item;

use MetaStore::Base;
use Data::Dumper;
use strict;
use warnings;

our @ISA = qw( MetaStore::Base );
our $VERSION = '0.01';
__PACKAGE__->attributes qw/ __init_rec  _attr/;

sub _init {
    my $self = shift;
    my $ref = shift;
    $ref->{id} or die "Need id !".__PACKAGE__;
    _attr $self $ref->{attr};
    __init_rec $self $ref;
    return $self->SUPER::_init(@_);
}

#method fo init
sub _create {
    my $self = shift;
}

sub _changed {
   my $self = shift;
    if ( my $ar = tied %{ $self->_attr } ) {
        return $ar->_changed;
    }
    return 0;
}

sub _get_attr {
    my $self = shift;
    return $self->_attr;
}

sub dump {
 my $self = shift;
 return $self->attr
}

sub restore {
    my $self= shift;
    if ( my $attr = shift ) {
        %{ $self->attr } =  %{$attr}
    }
}

sub attr {
    return $_[0]->_attr
}

sub id {
    my $self = shift;
    return $self->__init_rec->{id};
}



1;
__END__