File Coverage

blib/lib/PlugAuth/Role/Plugin.pm
Criterion Covered Total %
statement 24 24 100.0
branch 2 2 100.0
condition n/a
subroutine 10 10 100.0
pod 4 5 80.0
total 40 41 97.5


line stmt bran cond sub pod time code
1             package PlugAuth::Role::Plugin;
2              
3 41     41   17738 use strict;
  41         79  
  41         1483  
4 41     41   214 use warnings;
  41         81  
  41         1414  
5 41     41   1233 use 5.010001;
  41         148  
6 41     41   198 use Role::Tiny;
  41         174  
  41         331  
7              
8             # ABSTRACT: Role for PlugAuth plugins
9             our $VERSION = '0.35'; # VERSION
10              
11              
12       9 1   sub init { }
13              
14              
15             my $config;
16              
17             sub global_config
18             {
19 1594     1594 1 4899 $config;
20             }
21              
22              
23             sub plugin_config
24             {
25 9     9 1 139 shift->{plugin_config};
26             }
27              
28              
29             my $app;
30              
31             sub app
32             {
33 296     296 1 8530 $app;
34             }
35              
36             sub new
37             {
38 111     111 0 37415 my($class, $global_config, $plugin_config, $theapp) = @_;
39 111         222 $app = $theapp;
40 111         188 $config = $global_config;
41 111         505 my $self = bless {
42             plugin_config => $plugin_config,
43             }, $class;
44 111         597 $self->init;
45 111         2340 $self;
46             }
47              
48             # undocumented, may go away.
49             sub _self_auth_plugin
50             {
51 27     27   69 my($class, $new_value) = @_;
52            
53 27         47 state $plugin;
54            
55 27 100       265 $plugin = $new_value if defined $new_value;
56            
57 27         81 return $plugin;
58             }
59              
60             1;
61              
62             __END__
63              
64             =pod
65              
66             =encoding UTF-8
67              
68             =head1 NAME
69              
70             PlugAuth::Role::Plugin - Role for PlugAuth plugins
71              
72             =head1 VERSION
73              
74             version 0.35
75              
76             =head1 SYNOPSIS
77              
78             package PlugAuth::Plugin::MyPlugin;
79            
80             use Role::Tiny::With;
81            
82             with 'PlugAuth::Role::Plugin';
83            
84             sub init {
85             my($self) = @_;
86             # called immediately after plugin is
87             # created.
88             }
89            
90             1;
91              
92             =head1 DESCRIPTION
93              
94             Use this role when writing PlugAuth plugins.
95              
96             =head1 OPTIONAL ABSTRACT METHODS
97              
98             You may define these methods in your plugin.
99              
100             =head2 $plugin-E<gt>init
101              
102             This method is called after the object is created.
103              
104             =head1 METHODS
105              
106             =head2 $plugin-E<gt>global_config
107              
108             Get the global PlugAuth configuration (an instance of
109             L<Clustericious::Config>).
110              
111             =head2 $plugin-E<gt>plugin_config
112              
113             Get the plugin specific configuration. This
114             method may be called as either an instance or
115             class method.
116              
117             =head2 $plugin-E<gt>app
118              
119             Returns the L<PlugAuth> instance for the running PlugAuth server.
120              
121             =head1 SEE ALSO
122              
123             L<PlugAuth>,
124             L<PlugAuth::Guide::Plugin>
125              
126             =cut
127              
128             =head1 AUTHOR
129              
130             Graham Ollis <gollis@sesda3.com>
131              
132             =head1 COPYRIGHT AND LICENSE
133              
134             This software is copyright (c) 2012 by NASA GSFC.
135              
136             This is free software; you can redistribute it and/or modify it under
137             the same terms as the Perl 5 programming language system itself.
138              
139             =cut