diff options
Diffstat (limited to '')
-rw-r--r-- | Changes | 2 | ||||
-rw-r--r-- | lib/Net/HTTP/Spore.pm | 16 |
2 files changed, 10 insertions, 8 deletions
diff --git a/Changes b/Changes index 3d27d03..0e6c7bf 100644 --- a/Changes +++ b/Changes @@ -3,6 +3,8 @@ ordering in perl 5.17.6+ (#19) - Add support for PATCH HTTP method (#13, Andreas Marienborg) - Allow anonymous subs to be used as middleware (Brian Phillips) + - Refactor internals of Net::HTTP::Spore building of specs to allow easier + subclassing 0.05 Sun Nov 25 11:40:24 2012 - Fix a memory leak in Net::HTTP::Spore::Meta::Method (michaelr) diff --git a/lib/Net/HTTP/Spore.pm b/lib/Net/HTTP/Spore.pm index d4fd8af..d3b2165 100644 --- a/lib/Net/HTTP/Spore.pm +++ b/lib/Net/HTTP/Spore.pm @@ -22,7 +22,7 @@ sub new_from_string { Class::MOP::Class->create_anon_class( superclasses => ['Net::HTTP::Spore::Core'] ); - my $spore_object = _attach_spec_to_class($string, \%args, $spore_class); + my $spore_object = $class->_attach_spec_to_class($string, \%args, $spore_class); return $spore_object; } @@ -42,7 +42,7 @@ sub new_from_strings { my $spore_object = undef; foreach my $string (@strings) { - $spore_object = _attach_spec_to_class($string, $opts, $spore_class, $spore_object); + $spore_object = $class->_attach_spec_to_class($string, $opts, $spore_class, $spore_object); } return $spore_object; } @@ -75,7 +75,7 @@ sub new_from_specs { } sub _attach_spec_to_class { - my ( $string, $opts, $class, $object ) = @_; + my ( $class, $string, $opts, $spore_class, $object ) = @_; my $spec; try { @@ -98,9 +98,9 @@ sub _attach_spec_to_class { } if ( !$object ) { - $object = $class->new_object(%$opts); + $object = $spore_class->new_object(%$opts); } - $object = _add_methods( $object, $spec->{methods} ); + $object = $class->_add_methods( $object, $spec->{methods} ); } catch { Carp::confess( "unable to create new Net::HTTP::Spore object: " . $_ ); @@ -136,13 +136,13 @@ sub _read_spec { } sub _add_methods { - my ($class, $methods_spec) = @_; + my ($class, $spore, $methods_spec) = @_; foreach my $method_name (keys %$methods_spec) { - $class->meta->add_spore_method($method_name, + $spore->meta->add_spore_method($method_name, %{$methods_spec->{$method_name}}); } - $class; + $spore; } 1; |