You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently use Moose; use Magpie::Constants; works, but use Magpie::Constants; use Moose; does not work. This is down to the highly unconventional way that Magpie::Constants exports its constants.
Why not just...
package Magpie::Constants;
use constant => {
OK => 100,
DECLINED => 199,
# etc
};
use Sub::Exporter -setup => {
exports => [qw(OK DECLINED ...)],
groups => {
default => [qw(OK DECLINED ...)],
},
};
1;
Using Sub::Exporter also allows people to rename the constants easily:
use Magpie::Constants -all => { -prefix => 'MAGPIE_' };
sub GET { return MAGPIE_OK }
Using Sub::Exporter would also behave more sanely in conjunction with namespace::autoclean.
The text was updated successfully, but these errors were encountered:
This is just me trying to avoid yet another dependency but I think Sub::Exporter is req'd by Moose anyway so it's silly not to. Assigning this to myself.
Magpie::Constants was DIYing an Exporter unneccessarily. This fixes it
to use Sub::Exporter which is already brought in by Moose. This should
close bug #1 reported by tobyink.
Additionally we use some of the more advanced Sub::Exporter features to
allow adding custom HTTP methods beyond the core set defined by the
W3C/IETF.
use Magpie::Constants extra_http_methods => [qw(FOO BAR BAZ)] };
or
use Magpie::Constants HTTP_METHODS => {
extra_http_methods => [qw(FOO BAR BAZ)]
};
Should both now work. This closes bug #4 reported by tobyink.
Tests are left as a lemma for the reader (currently).
Currently
use Moose; use Magpie::Constants;
works, butuse Magpie::Constants; use Moose;
does not work. This is down to the highly unconventional way that Magpie::Constants exports its constants.Why not just...
Using Sub::Exporter also allows people to rename the constants easily:
Using Sub::Exporter would also behave more sanely in conjunction with namespace::autoclean.
The text was updated successfully, but these errors were encountered: