NAME
Ambrosia::DataProvider - a container for data sources. (Singleton)
VERSION
version 0.010
SYNOPSIS
use Ambrosia::DataProvider;
my $confDS = {
DBI => [
{
engine_name => 'DB::mysql',
source_name => 'Employee',
engine_params => 'database=EmployeeDB;host=localhost;',
user => 'test',
password => 'test',
additional_params => { AutoCommit => 0, RaiseError => 1, LongTruncOk => 1 },
additional_action => sub { my $dbh = shift; $dbh->do('SET NAMES utf8')},
},
#........
],
IO => [
{
engine_name => 'IO::CGI',
source_name => 'cgi',
engine_params => {
header_params => {
'-Pragma' => 'no-cache',
'-Cache_Control' => 'no-cache, must-revalidate, no-store'
}
}
}
],
};
instance Ambrosia::Storage(application_name => $confDS);
Ambrosia::DataProvider::assign 'application_name';
DESCRIPTION
Ambrosia::DataProvider is a container for data sources. (Singleton)
For more information see:
- Ambrosia::DataProvider::DBIDriver
- Ambrosia::DataProvider::IODriver
- Ambrosia::DataProvider::ResourceDriver
SUBROUTINES/METHODS
instance
Static subrutine. Creates a singleton container.
instance('storage_name' => $config_data)
Structure of config data:
config = {
DRIVER_TYPE => [
engine_name => 'ENGINE_FOR_DRIVER_TYPE',
source_name => 'UNIQ_NAME_FOR_SOURCE_DATA',
engine_params => 'PARAMS_FOR_ENGINE',
%ANY_ADDITIONAL_PARAMS_FOR_DRIVER_TYPE
]
}
assign
Static subrutine. Assigns a current process to a named data source from container. assign('storage_name')
storage
Static subrutine. Returns container assigned to current process. storage() storage('storage_name')
add_source
Method. Adds or changes a data source into container. storage()->add_source($config_data)
driver
Method. Returns a driver from container by driver type and source name. storage()->driver($driverType, $sourceName)
DIAGNOSTICS
CONFIGURATION AND ENVIRONMENT
DEPENDENCIES
Ambrosia::core::ClassFactory Ambrosia::Assert
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)