Commit | Line | Data |
d80786d0 |
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; |