Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
IOC::Service::Literal(User Contributed Perl DocumentatIOC::Service::Literal(3)

NAME
       IOC::Service::Literal - An IOC Service object whose component is	a
       literal value

SYNOPSIS
	 use IOC::Service::Literal;

	 my $container = IOC::Container->new();
	 # use a literal here for our log_file
	 $container->register(IOC::Service::Literal->new('log_file' => "logfile.log" ));
	 $container->register(IOC::Service->new('logger' => sub	{
	     my	$c = shift;
	     return FileLogger->new($c->get('log_file'));
	 }));
	 $container->register(IOC::Service->new('application' => sub {
	     my	$c = shift;
	     my	$app = Application->new();
	     $app->logger($c->get('logger'));
	     return $app;
	 }));

	 $container->get('application')->run();

DESCRIPTION
       In this IOC framework, the IOC::Service::Literal	object holds a literal
       value which does	not need to be initialized. This IOC::Service subclass
       is specifically optimized to handle values which	need no
       initialization, like literal values, such as numbers and	strings. It is
       sometimes useful	for these types	of values to be	included in your
       configuration, this helps reduce	the overhead for them.

	       +--------------+
	       | IOC::Service |
	       +--------------+
		     |
		     ^
		     |
	  +-----------------------+		    +-----------------+
	  | IOC::Service::Literal |---(instance)--->| <Literal Value> |
	  +-----------------------+		    +-----------------+

METHODS
       new ($name, $literal)
	   Creates a service with a $name, and uses the	$literal value which
	   need	not be initialized.

       name
	   Returns the name of the service instance.

       setContainer ($container)
	   This	is a no-op method, since the service is	not initialized, then
	   it does not need an instance	of the container.

       removeContainer
	   This	is a no-op method, see "setContainer" above.

       instance
	   This	method returns the literal value held by the service object.

TO DO
       Work on the documentation

BUGS
       None that I am aware of.	Of course, if you find a bug, let me know, and
       I will be sure to fix it.

CODE COVERAGE
       I use Devel::Cover to test the code coverage of my tests, see the CODE
       COVERAGE	section	of IOC for more	information.

SEE ALSO
AUTHOR
       stevan little, <stevan@iinteractive.com>

COPYRIGHT AND LICENSE
       Copyright 2004-2007 by Infinity Interactive, Inc.

       <http://www.iinteractive.com>

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

perl v5.32.1			  2007-04-22	      IOC::Service::Literal(3)

NAME | SYNOPSIS | DESCRIPTION | METHODS | TO DO | BUGS | CODE COVERAGE | SEE ALSO | AUTHOR | COPYRIGHT AND LICENSE

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=IOC::Service::Literal&sektion=3&manpath=FreeBSD+13.0-RELEASE+and+Ports>

home | help