aboutsummaryrefslogtreecommitdiff
path: root/lib/Net/Hawk/Role/WithCrypto.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Net/Hawk/Role/WithCrypto.pm')
-rw-r--r--lib/Net/Hawk/Role/WithCrypto.pm24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/Net/Hawk/Role/WithCrypto.pm b/lib/Net/Hawk/Role/WithCrypto.pm
new file mode 100644
index 0000000..d8d95e9
--- /dev/null
+++ b/lib/Net/Hawk/Role/WithCrypto.pm
@@ -0,0 +1,24 @@
+package Net::Hawk::Role::WithCrypto;
+use strict;
+use warnings;
+use 5.010;
+use Package::Variant
+ importing => ['Moo::Role'],
+ subs => ['has'];
+use Types::Standard 1.000003 qw(HasMethods);
+
+sub make_variant {
+ my ($class,$target_package,@methods) = @_;
+
+ has _crypto => (
+ is => 'ro',
+ (@methods ? ( isa => HasMethods[@methods] ) : () ),
+ init_arg => 'crypto',
+ default => sub {
+ require Net::Hawk::Crypto;
+ Net::Hawk::Crypto->new;
+ },
+ );
+}
+
+1;