Commit | Line | Data |
9d159224 |
1 | package Web::Simple; |
2 | |
3 | use strict; |
4 | use warnings FATAL => 'all'; |
5 | |
6 | sub import { |
7 | strict->import; |
8 | warnings->import(FATAL => 'all'); |
9 | warnings->unimport('syntax'); |
10 | warnings->import(FATAL => qw( |
11 | ambiguous bareword digit parenthesis precedence printf |
12 | prototype qw reserved semicolon |
13 | )); |
14 | my ($class, $app_package) = @_; |
15 | $class->_export_into($app_package); |
16 | } |
17 | |
18 | sub _export_into { |
19 | my ($class, $app_package) = @_; |
20 | { |
21 | no strict 'refs'; |
22 | *{"${app_package}::dispatch"} = sub { |
23 | $app_package->_setup_dispatchables(@_); |
24 | }; |
25 | *{"${app_package}::filter_response"} = sub (&) { |
26 | $app_package->_construct_response_filter($_[0]); |
27 | }; |
28 | *{"${app_package}::redispatch_to"} = sub { |
29 | $app_package->_construct_redispatch($_[0]); |
30 | }; |
31 | *{"${app_package}::default_config"} = sub { |
32 | my @defaults = @_; |
33 | *{"${app_package}::_default_config"} = sub { @defaults }; |
34 | }; |
35 | *{"${app_package}::self"} = \${"${app_package}::self"}; |
36 | require Web::Simple::Application; |
37 | unshift(@{"${app_package}::ISA"}, 'Web::Simple::Application'); |
38 | } |
39 | } |
40 | |
41 | 1; |