Salvation::Service::Hook - Base class for a hook
package YourSystem::Services::SomeService::Hooks::SomeType::SomeValue; use Moose; extends 'Salvation::Service::Hook'; no Moose;
Moose
A special object used to override service's behaviour.
If the service has the hook and the hook has one or more things which can override service's original ones - hook ones will be used.
In example, if service S has its own view (S::Defaults::V) and model (S::Defaults::M), and uses a hook right now (S::Hooks::ExampleType::ExampleValue) which on its own has only a view (S::Hooks::ExampleType::ExampleValue::Defaults::V) then S will use S::Defaults::M as the model and S::Hooks::ExampleType::ExampleValue::Defaults::V as the view. This could be done with view, model, countroller and output processor. DataSet is unhookable.
S
S::Defaults::V
S::Defaults::M
S::Hooks::ExampleType::ExampleValue
S::Hooks::ExampleType::ExampleValue::Defaults::V
Also you can define init and main methods for your hook to override service's ones (which are still accessible via SUPER::).
init
main
SUPER::
A hook can Call and Hook too, as it is just a subclass of a service. The second gives you an ability to create chained hooks.
Call
Hook
In addition to previous example, let's imagine that S::Hooks::ExampleType::ExampleValue uses its own hook right now, say it is S::Hooks::ExampleType::ExampleValue::Hooks::ExampleType2::ExampleValue2 which has a controller (S::Hooks::ExampleType::ExampleValue::Hooks::ExampleType2::ExampleValue2::Defaults::C). Then the service's contoller will be S::Hooks::ExampleType::ExampleValue::Hooks::ExampleType2::ExampleValue2::Defaults::C instead of possible S::Hooks::ExampleType::ExampleValue::Defaults::C or its original S::Defaults::C if it had any.
S::Hooks::ExampleType::ExampleValue::Hooks::ExampleType2::ExampleValue2
S::Hooks::ExampleType::ExampleValue::Hooks::ExampleType2::ExampleValue2::Defaults::C
S::Hooks::ExampleType::ExampleValue::Defaults::C
S::Defaults::C
To define a hook, two things should be done:
Salvation::Service::Hook
Salvation::Service
To install Salvation, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Salvation
CPAN shell
perl -MCPAN -e shell install Salvation
For more information on module installation, please visit the detailed CPAN module installation guide.