Hoppy::Base - Base class.


Hoppy documentation Contained in the Hoppy distribution.

Index


Code Index:

NAME

Top

Hoppy::Base - Base class.

SYNOPSIS

Top

  package My::Class;
  use base qw(Hoppy::Base);

DESCRIPTION

Top

Base class of Hoppy application.

METHODS

Top

new

mk_virtual_methods

AUTHOR

Top

Takeshi Miki <miki@cpan.org>

LICENSE

Top

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

SEE ALSO

Top


Hoppy documentation Contained in the Hoppy distribution.

package Hoppy::Base;
use strict;
use warnings;
use Carp;
use base qw(Class::Accessor::Fast Class::Data::ConfigHash);

$|++;

__PACKAGE__->mk_accessors($_) for qw(context);

sub new {
    my $class  = shift;
    my %args   = @_;
    my $config = delete $args{config};
    my $self   = $class->SUPER::new( {@_} );
    $self->config($config) if $config;
    return $self;
}

sub mk_virtual_methods {
    my $class = shift;
    foreach my $method (@_) {
        my $slot = "${class}::${method}";
        {
            no strict 'refs';
            *{$slot} = sub {
                Carp::croak( ref( $_[0] ) . "::${method} is not overridden" );
              }
        }
    }
    return ();
}

1;
__END__