The Perl Advent Calendar needs more articles for 2022. Submit your idea today!
package Bread::Board::Literal;
our $AUTHORITY = 'cpan:STEVAN';
# ABSTRACT: service providing a literal value
$Bread::Board::Literal::VERSION = '0.37';
use Moose;

with 'Bread::Board::Service';

has 'value' => (
    is       => 'rw',
    required => 1,

sub get { (shift)->value }

sub clone_and_inherit_params {
    confess 'Trying to inherit from a literal service';


no Moose; 1;



=encoding UTF-8

=head1 NAME

Bread::Board::Literal - service providing a literal value

=head1 VERSION

version 0.37


  my $c = container PrettyBoring => as {

      # These are Bread::Board::Literal services
      service connect_string => 'dbi:mysql:boring_db';
      service service_url => '';

      # And some other services depending on them...

      service dbconn => (
          class => 'DBI',
          block => sub {
              my $s = shift;
          dependencies => wire_names(qw( connect_string )),

      service service_request => (
          class => 'HTTP::Request',
          block => sub {
              my $s = shift;
              HTTP::Request->new(POST => $s->param('service_url'));
          dependencies => wire_names(qw( service_url ));

  # OR to use directly:
  my $literal = Bread::Board::Literal->new(
      name  => 'the_answer_to_life_the_universe_and_everything',
      value => 42,


A literal service is one that stores a literal scalar or reference for use in
your Bread::Board.

Beware of using references in your literals as they may cause your Bread::Board
to leak memory. If this is a concern, you may want to weaken your references.

See L<Scalar::Util/weaken>.


=head2 C<value>

Required attribute with read/write accessor. This is the value that
L</get> will return.

=head1 METHODS

=head2 C<get>

Returns the L</value>, unaltered.

=head2 C<clone_and_inherit_params>

Dies: a literal service is (essentially) a constant, it does not make
sense to inherit from it.

=head1 AUTHOR

Stevan Little <>

=head1 BUGS

Please report any bugs or feature requests on the bugtracker website

When submitting a bug or request, please include a test-file or a
patch to an existing test-file that illustrates the bug or desired


This software is copyright (c) 2019, 2017, 2016, 2015, 2014, 2013, 2011, 2009 by Infinity Interactive.

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