Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

containerでcontainerをexportしないフラグを用意した

  • Loading branch information...
commit baa702ad79b86145d34a879c8208301b2b158786 1 parent 316e2c1
@nekokak authored
Showing with 23 additions and 1 deletion.
  1. +5 −1 lib/Kamui/Container.pm
  2. +18 −0 t/010_container/no_export.t
View
6 lib/Kamui/Container.pm
@@ -9,6 +9,7 @@ my $_register_namespace = +{};
sub import {
my ($class, @opts) = @_;
+
my $caller = caller;
if (scalar(@opts) == 1 and ($opts[0]||'') =~ /^-base$/i) {
@@ -33,7 +34,10 @@ sub import {
$class->_export_functions($caller => @opts);
}
- $class->_export_container($caller);
+ unless (($opts[0]||'') =~ /^-no_export$/i) {
+ $class->_export_container($caller);
+ }
+
$class->initialize;
}
View
18 t/010_container/no_export.t
@@ -0,0 +1,18 @@
+use t::Utils;
+use Test::More;
+use Mock::Container -no_export;
+
+subtest 'no export container' => sub {
+ ok not main->can('container');
+ done_testing;
+};
+
+subtest 'new' => sub {
+ my $obj = Mock::Container->instance;
+ isa_ok $obj, 'Mock::Container';
+ is_deeply $obj->get('conf')->{conf_test}, +{ foo => 'bar', name => 'nekokak' };
+ done_testing;
+};
+
+done_testing;
+
Please sign in to comment.
Something went wrong with that request. Please try again.