NAME
Ambrosia::core::ClassFactory - a factory of classes.
VERSION
version 0.010
SYNOPSIS
require
Ambrosia::core::ClassFactory;
#In memory (on fly)
Ambrosia::core::ClassFactory::create(
'Employes::Person'
, {
public
=>
qw/FirstName LastName Age/
});
my
$p
= new Employes::Person(
FirstName
=>
'John'
,
LastName
=>
'Smith'
,
Age
=> 33);
#From module Employes/Person.pm (Employes::Person created by Ambrosia::Meta)
my
$p
= Ambrosia::core::ClassFactory::create_object(
'Employes::Person'
, (
FirstName
=>
'John'
,
LastName
=>
'Smith'
,
Age
=> 33));
$p
->FirstName;
#John
DESCRIPTION
Ambrosia::core::ClassFactory
is a factory of classes that allows to produce classes on the fly, to create objects of certain type and just to load packages.
SUBROUTINES
create ($package, $fields)
Produces class of represented type dynamically
with
represented fields.
create(
$package
,
$fields
);
in params:
$package
- name of class (
'Foo::Bar::Baz'
)
$fields
- hash. See L<Ambrosia::Meta>
create_object ($package, %params)
Loads the
package
and creates the appropriate object and initializes it by the specified parameters.
in params:
$package
- name of class (
'Foo::Bar::Baz'
)
%params
- data hash.
load_class ($package)
generally by aliasing certain subroutine or variable names into your
package
.
It is exactly equivalent to B<
use
> but without B<BEGIN>
in params:
$package
- name of class (
'Foo::Bar::Baz'
)
DEPENDENCIES
Ambrosia::core::Exceptions Ambrosia::Meta
THREADS
Not tested.
BUGS
Please report bugs relevant to Ambrosia
to <knm[at]cpan.org>.
COPYRIGHT AND LICENSE
Copyright (C) 2010-2012 Nickolay Kuritsyn. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
AUTHOR
Nikolay Kuritsyn (knm[at]cpan.org)