3620e26c768da1865bdd57167153dc2b917d2e90
[catagits/HTML-Zoom.git] / lib / HTML / Zoom / SubObject.pm
1 package HTML::Zoom::SubObject;
2
3 use strict;
4 use warnings FATAL => 'all';
5 use Scalar::Util ();
6
7 sub new {
8   my ($class, $args) = @_;
9   ($args||={})->{zconfig} ||= do {
10     require HTML::Zoom::ZConfig;
11     HTML::Zoom::ZConfig->new
12   };
13   my $new = { _zconfig => $args->{zconfig} };
14   Scalar::Util::weaken($new->{_zconfig});
15   bless($new, $class)
16 }
17
18 sub _zconfig { shift->{_zconfig} }
19
20 sub with_zconfig {
21   my ($self, $zconfig) = @_;
22   my $new = bless({ %$self, _zconfig => $zconfig }, ref($self));
23   Scalar::Util::weaken($new->{_zconfig});
24   $new
25 }
26
27 1;