package Text::Diff3::Base;
use 5.006;
use strict;
use warnings;

use version; our $VERSION = '0.08';


sub new {
    my($class, @arg) = @_;
    my $self = bless {}, $class;
    return $self;

sub initialize {
    my($self, $f) = @_;
    return $self;

sub mk_attr_accessor {
    my($class, @fields) = @_;
    $class = ref $class ? ref $class : $class;
    for my $field (@fields) {
        my $accessor = $class->_accessor($field);
        no strict 'refs';
        *{"${class}::${field}"} = $accessor;

sub _accessor {
    my($class, $field) = @_;
    return sub{
        my($self, @arg) = @_;
        if (@arg) {
            $self->{$field} = $arg[0];
        return $self->{$field};




=head1 NAME

Text::Diff3::Base - Text::Diff3 component's base class

=head1 VERSION



    package Text::Diff3::COMPONENT;
    use base qw(Text::Diff3::Base);
    __PACKAGE__->mk_attr_accessor(qw(attr1_name attr2_name));


This module is the base class for all Text::Diff3 components.

=head1 METHODS


=item C<< $factory_name->new($factory_name => @arg) >>

creates an instance of COMPONENT with the initialize method.

=item C<< $component->factory >>

is an attribute to hold factory class name.

=item C<< $component->initialize($factory_name => @arg) >>

is the default initializer for components.
This sets passed name into the factory attribute.

=item C<< $component->mk_attr_accessor(qw(attr1_name attr2_name)) >>

declares attribute accessors in package.



Use new function style interfaces introduced from version 0.08.
This module remained for backward compatibility before version 0.07.
This module is no longer maintenance after version 0.08.

=head1 AUTHOR

MIZUTANI Tociyuki C<< <> >>.


Copyright (C) 2010 MIZUTANI Tociyuki

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.