diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2016-09-22 16:12:40 +0100 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2017-02-15 17:27:29 +0000 |
commit | 34795d026faf45b0a1bfc103362eb118766c46d7 (patch) | |
tree | fc43f5c09c7b4bfe033d99ff3380cb5bcdc771b4 /perllib/FixMyStreet/Cobrand | |
parent | 54af489f0fe985dfc433f0b8a3ab226a470a6023 (diff) |
Add cobrand call_hook fn, calls a fn if defined.
Diffstat (limited to 'perllib/FixMyStreet/Cobrand')
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Base.pm | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Base.pm b/perllib/FixMyStreet/Cobrand/Base.pm index a9eed0018..ea2b8f410 100644 --- a/perllib/FixMyStreet/Cobrand/Base.pm +++ b/perllib/FixMyStreet/Cobrand/Base.pm @@ -65,6 +65,18 @@ sub is_default { return $self->moniker eq 'default'; } +=head2 call_hook + + $cobrand->call_hook(foo => 1, 2, 3); # calls $cobrand->foo(1, 2, 3) if it exists + +=cut + +sub call_hook { + my ($self, $method_name, @args) = @_; + my $method = $self->can($method_name) or return; + return $self->$method(@args); +} + # NB: this Base class is for 'meta' features. To add base methods for all cobrands, # you may want to look at FMS::Cobrand::Default instead! |