Context-Singleton

 view release on metacpan or  search on metacpan

t/Context-Singleton-Frame.t  view on Meta::CPAN

		$object->deduce (q (constant));

		object      => $object,
		with_rule   => q (constant),
		with_value  => q (foo),
		throws      => q (Context::Singleton::Exception::Deduced),
	};

	test_method_proclaim q (should throw when rule is already deduce()-ed as dependency) => do {
		my $object = build_frame;
		$object->deduce (q (cascaded));

		object      => $object,
		with_rule   => q (constant),
		with_value  => q (foo),
		throws      => q (Context::Singleton::Exception::Deduced),
	};

	test_method_proclaim q (should proclaim() rule with known builder after its deduce() failed) => do {
		my $object = build_frame;
		$object->try_deduce (q (with_deps));

t/Context-Singleton-Frame.t  view on Meta::CPAN

	};

	should_be_deduced       q (after deduce() should be deduced) => do {
		my $object = build_frame;
		$object->deduce (q (constant));

		object     => $object,
		with_rule  => q (constant),
	};

	should_be_deduced       q (after cascaded deduce() should be deduced) => do {
		my $object = build_frame;
		$object->deduce (q (cascaded));

		object     => $object,
		with_rule  => q (constant),
	};

	should_not_be_deduced   q (after unsuccessful cascaded deduce() should not be deduced) => do {
		my $object = build_frame;
		$object->try_deduce (q (with_multi_deps));

		object     => $object,
		with_rule  => q (constant),
	};

	return;
};

t/Context-Singleton-Frame.t  view on Meta::CPAN

	};

	should_be_deducible     q (after deduce() should be deducible) => do {
		my $object = build_frame;
		$object->deduce (q (constant));

		object      => $object,
		with_rule   => q (constant),
	};

	should_be_deducible     q (after cascaded deduce() should be deducible) => do {
		my $object = build_frame;
		$object->deduce (q (cascaded));

		object      => $object,
		with_rule   => q (constant),
	};

	return;
};

describe_method q (deduce) => [qw[ rule ]]         => as {
	shared->frame_class = q (Sample::Context::Singleton::Frame::__::Basic);

t/lib/Sample/Context/Singleton/Frame.pm  view on Meta::CPAN

		as => sub { join q (/), @_ },
		default => { foo => q (value), bar => 42 },
		dep => [ q (foo), q (bar) ],
	));

	$self->db->contrive (with_deps => (
		as => sub { join q (-), @_ },
		dep => [ q (foo), q (bar) ],
	));

	$self->db->contrive (cascaded => (
		as => sub { join q (:), q (cascaded), @_ },
		default => { param => q (param) },
		dep => [ q (param), q (with_deps) ],
	));

	$self->db->trigger (with_trigger => sub {
		my $copy = q (copy_trigger);
		$self->proclaim ($copy, $_[0])
			unless $self->is_deduced ($copy)
			;
	});

t/lib/Sample/Context/Singleton/Frame.pm  view on Meta::CPAN

use Moo;
BEGIN { extends q (Sample::Context::Singleton::Frame::001::Unique::DB) }

sub BUILD {
	my ($self) = @_;

	$self->contrive (constant => (
		value => q (value-42),
	));

	$self->contrive (cascaded => (
		dep => [ q (constant) ],
		as => sub { qq (cascaded:$_[0]) },
	));

	$self->contrive (with_deps => (
		dep => [ q (unknown) ],
		as => sub { qq (with_deps:$_[0]) },
	));

	$self->contrive (with_multi_deps => (
		dep => [ q (unknown), q (constant) ],
		as => sub { qq (with_deps:$_[0]:$_[1]) },



( run in 0.819 second using v1.01-cache-2.11-cpan-e7c6538aa59 )