Class-Container

 view release on metacpan or  search on metacpan

Build.PL  view on Meta::CPAN



my %module_build_args = (
  "build_requires" => {
    "Module::Build" => "0.3601"
  },
  "configure_requires" => {
    "ExtUtils::MakeMaker" => "6.30",
    "Module::Build" => "0.3601"
  },
  "dist_abstract" => "Glues object frameworks together transparently",
  "dist_author" => [
    "Ken Williams <kwilliams\@cpan.org>"
  ],
  "dist_name" => "Class-Container",
  "dist_version" => "0.13",
  "license" => "perl",
  "module_name" => "Class::Container",
  "recommends" => {},
  "recursive_test_files" => 1,
  "requires" => {

META.yml  view on Meta::CPAN

---
abstract: 'Glues object frameworks together transparently'
author:
  - 'Ken Williams <kwilliams@cpan.org>'
build_requires:
  File::Spec: 0
  Module::Build: 0.3601
  Test: 0
configure_requires:
  ExtUtils::MakeMaker: 6.30
  Module::Build: 0.3601
dynamic_config: 0

Makefile.PL  view on Meta::CPAN

use strict;
use warnings;



use ExtUtils::MakeMaker 6.30;



my %WriteMakefileArgs = (
  "ABSTRACT" => "Glues object frameworks together transparently",
  "AUTHOR" => "Ken Williams <kwilliams\@cpan.org>",
  "BUILD_REQUIRES" => {
    "Module::Build" => "0.3601"
  },
  "CONFIGURE_REQUIRES" => {
    "ExtUtils::MakeMaker" => "6.30",
    "Module::Build" => "0.3601"
  },
  "DISTNAME" => "Class-Container",
  "EXE_FILES" => [],

README  view on Meta::CPAN



This archive contains the distribution Class-Container,
version 0.13:

  Glues object frameworks together transparently

This software is copyright (c) 2017 by Ken Williams.

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


lib/Class/Container.pm  view on Meta::CPAN

    Scalar::Util->import('weaken');
    $HAVE_WEAKEN = 1;
  };
  
  *weaken = sub {} unless defined &weaken;
}

use Carp;

# The create_contained_objects() method lets one object
# (e.g. Compiler) transparently create another (e.g. Lexer) by passing
# creator parameters through to the created object.
#
# Any auto-created objects should be declared in a class's
# %CONTAINED_OBJECTS hash.  The keys of this hash are objects which
# can be created and the values are the default classes to use.

# For instance, the key 'lexer' indicates that a 'lexer' parameter
# should be silently passed through, and a 'lexer_class' parameter
# will trigger the creation of an object whose class is specified by
# the value.  If no value is present there, the value of 'lexer' in

lib/Class/Container.pm  view on Meta::CPAN

sub validation_spec {
  return (ref($_[0]) || $_[0])->_iterate_ISA(\%VALID_PARAMS, \%VALID_CACHE, { container => {type => HASHREF} });
}

1;

__END__

=head1 NAME

Class::Container - Glues object frameworks together transparently

=head1 VERSION

version 0.13

=head1 SYNOPSIS

 package Car;
 use Class::Container;
 @ISA = qw(Class::Container);

lib/Class/Container.pm  view on Meta::CPAN

   $self->{right_wheel} = $self->create_delayed_object('wheel');
   ... do any more initialization here ...
   return $self;
 }

=head1 DESCRIPTION

This class facilitates building frameworks of several classes that
inter-operate.  It was first designed and built for C<HTML::Mason>, in
which the Compiler, Lexer, Interpreter, Resolver, Component, Buffer,
and several other objects must create each other transparently,
passing the appropriate parameters to the right class, possibly
substituting other subclasses for any of these objects.

The main features of C<Class::Container> are:

=over 4

=item *

Explicit declaration of containment relationships (aggregation,

lib/Class/Container.pm  view on Meta::CPAN

class framework

=item *

Transparent passing of constructor parameters to the class
that needs them

=item *

Ability to create one (automatic) or many (manual) contained
objects automatically and transparently

=back

=head2 Scenario

Suppose you've got a class called C<Parent>, which contains an object of
the class C<Child>, which in turn contains an object of the class
C<GrandChild>.  Each class creates the object that it contains.
Each class also accepts a set of named parameters in its
C<new()> method.  Without using C<Class::Container>, C<Parent> will



( run in 0.489 second using v1.01-cache-2.11-cpan-0a6323c29d9 )