package Dancer::Object; # This class is a root class for each
object in Dancer. # It provides basic OO tools for Perl5 without
being... Moose ;-) use strict; use warnings; use Carp; use
Dancer::Exception qw(:all); # constructor sub new { my ($class,
%args) = @_; my $self = \%args; bless $self, $class;
$self->init(%args); return $self; } sub clone { my ($self) = @_;
raise core => "The 'Clone' module is needed" unless
Dancer::ModuleLoader->load('Clone'); return Clone::clone($self);
} # initializer sub init {1} # meta information about classes my
$_attrs_per_class = {}; sub get_attributes { my ($class,
$visited_parents) = @_; # $visited_parents keeps track of parent
classes we already handled, to # avoid infinite recursion (in
case of dependancies loop). It's not stored as class singleton,
otherwise # get_attributes wouldn't be re-entrant.
$visited_parents ||= {}; my @attributes =
@{$_attrs_per_class->{$class} || [] }; my @parents; { no strict
'refs'; @parents = @{"$class\::ISA"}; } foreach my $parent
(@parents)