| 1 | # Copyright 2009, 2010 Kevin Ryde | ||
| 2 | |||
| 3 | # This file is part of Chart. | ||
| 4 | # | ||
| 5 | # Chart is free software; you can redistribute it and/or modify it under the | ||
| 6 | # terms of the GNU General Public License as published by the Free Software | ||
| 7 | # Foundation; either version 3, or (at your option) any later version. | ||
| 8 | # | ||
| 9 | # Chart is distributed in the hope that it will be useful, but WITHOUT ANY | ||
| 10 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
| 11 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
| 12 | # details. | ||
| 13 | # | ||
| 14 | # You should have received a copy of the GNU General Public License along | ||
| 15 | # with Chart. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | |||
| 17 | package App::Chart::Tie::GetSetMethod; | ||
| 18 | use strict; | ||
| 19 | use warnings; | ||
| 20 | |||
| 21 | sub TIESCALAR { | ||
| 22 | my ($class, $obj, $method) = @_; | ||
| 23 | my $oldval = $obj->$method; | ||
| 24 | return bless [$obj, $method, $oldval], $class; | ||
| 25 | } | ||
| 26 | sub FETCH { | ||
| 27 | my ($self) = @_; | ||
| 28 | my ($obj, $method) = @$self; | ||
| 29 | return $obj->$method; | ||
| 30 | } | ||
| 31 | sub STORE { | ||
| 32 | my ($self, $value) = @_; | ||
| 33 | my ($obj, $method) = @$self; | ||
| 34 | return $obj->$method ($value); | ||
| 35 | } | ||
| 36 | sub UNTIE { | ||
| 37 | my ($self) = @_; | ||
| 38 | my ($obj, $method, $oldval) = @$self; | ||
| 39 | return $obj->$method ($oldval); | ||
| 40 | } | ||
| 41 | |||
| 42 | 1; | ||
| 43 | __END__ |