Ambrosia

 view release on metacpan or  search on metacpan

lib/Ambrosia/Config.pm  view on Meta::CPAN

201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
=head2 instance
 
This method instantiates the named object of type C<Ambrosia::Config> in the pool.
This method not exported. Use as constructor: C<instance Ambrosia::Config(.....)>
C<instance(name =&gt; path)> - where the "name" is a keyname for config and the "path" is a path to config file.
C<instance(name =&gt; hash)> - where the "name" is a keyname for config and the "hash" is a config data.
 
=head2 config
 
Returns the global object of type C<Ambrosia::Config>.
C<config(name)> - the "name" is optional param. Call with "name" if you not assign current process to config.
 
=head2 assign ($name)
 
Assign current process to the global named object of type C<Ambrosia::Config>.
 
=head1 DEPENDENCIES
 
L<Ambrosia::core::Exceptions>
L<Ambrosia::Meta>
 
=head1 THREADS
 
Not tested.

lib/Ambrosia/Context.pm  view on Meta::CPAN

251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
Creates an object of type of C<Ambrosia::Context>.
 
=head1 METHODS
 
=head2 destroy
 
Destroys a context. You must call this method when session finished.
 
=head2 Context
 
Returns global an object of type of C<Ambrosia::Context>.
 
=head1 THREADS
 
Not tested.
 
=head1 BUGS
 
Please report bugs relevant to C<Ambrosia> to <knm[at]cpan.org>.
 
=head1 COPYRIGHT AND LICENSE

lib/Ambrosia/Logger.pm  view on Meta::CPAN

222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
sub DESTROY
{}
 
1;
 
__END__
 
=head1 NAME
 
Ambrosia::Logger - a class for create global object for logging.
 
=head1 VERSION
 
version 0.010
 
=head1 SYNOPSIS
 
    use Ambrosia::Logger;
    BEGIN {
        instance Ambrosia::Logger('myApplication', DEBUG => 1, INFO_EX => 1, INFO => 1, -prefix => 'GoogleCoupon_', -dir => $logger_path);

lib/Ambrosia/Logger.pm  view on Meta::CPAN

244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
    }
 
    logger->log('is just message', 'other message' );
    logger->log_info('is simple info', ... );
    logger->log_info_ex('is dump of structures info', {foo=>1}, [{bar=>1},{baz=>2}] );
    logger->error('message about errors');
    logger->debug('write with the message and the stack of calls');
 
=head1 DESCRIPTION
 
C<Ambrosia::Logger> is a class for create global object for logging.
Implement the pattern B<Singleton>.
 
=head2 instance
 
Instances the named object of type C<Ambrosia::Logger> in the pool.
This method not exported. Use as constructor: C<instance Ambrosia::Logger(.....)>
 
=head2 logger
 
Returns the global object of type C<Ambrosia::Logger>.
C<logger(name)> - the name is optional param. Call with name if you not assign current process to logger yet.
 
=head2 assign
 
Assigns current process to the global named object of type C<Ambrosia::Logger>.
 
=head1 DEPENDENCIES
 
L<File::Path>
L<IO::File>
L<Data::Dumper>
L<Time::HiRes>
L<Scalar::Util>
L<Exporter>
L<Ambrosia::error::Exceptions>

lib/Ambrosia/Utils/Container.pm  view on Meta::CPAN

153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
package deferred;
 
 
    '%{}' => \&as_hash,
    '@{}' => \&__as_array,
    '${}' => \&__as_scalar,
    '&{}' => \&__as_func,
    '*{}' => \&__as_glob,
    '==' => \&__as_bool,
    'bool'=> \&__as_bool,
    '""'  => \&__as_string,
    '0+'  => \&__as_number,
    'fallback' => 1
    ;
 
sub call(&)
{
    return bless {code => $_[0]}, 'deferred';

lib/Ambrosia/Utils/Container.pm  view on Meta::CPAN

218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
    #    $_[0]->{scalar} = '' . $_[0]->{code}->();
    #}
    #return $_[0]->{scalar};
}
 
sub __as_func
{
    goto &__as_any;
}
 
sub __as_glob
{
    goto &__as_any;
}
 
sub __as_bool
{
    goto &__as_any;
    #unless ( exists $_[0]->{bool} )
    #{
    #    $_[0]->{bool} = '' . $_[0]->{code}->();

t/Ambrosia/Event.t  view on Meta::CPAN

48
49
50
51
52
53
54
55
56
57
58
59
    $foo->run();
    ok($foo->foo == 2, 'fire event with ignore previos'); #test #3
 
    $foo->on_run(sub {$foo->foo=3; return 0;});
    $foo->run();
    ok($foo->foo == 4, 'fire event throw chain previos'); #test #4
 
    my $abort = 0;
    Ambrosia::Event::attachHandler('','on_abort', sub {$abort=123});
    $foo->abort();
    ok($abort == 123, 'global event');
}



( run in 0.297 second using v1.01-cache-2.11-cpan-a9ef4e587e4 )