URI::Platonic を Decorator として動作するようにしてみた
id:miyagawa さんにもらったコメントを参考にやってみた.ほとんどのメソッドは URI オブジェクト側に流すようにしたんだけど,正直 AUTOLOAD とか今まで全然使ってなかったのでコード微妙かも.添削してほしい感じ.
http://coderepos.org/share/changeset/7441
あまり問題なければ CPAN にうpして実践投入したい.
抜粋
use URI; use URI::Platonic; my $uri = URI->new("http://example.com/path/to/resource.html"); my $platonic = URI::Platonic->new($uri); $platonic->path; # "/path/to/resource" $platonic->extension; # "html" $platonic->as_string; # "http://example.com/path/to/resource" $platonic->distinct; # "http://example.com/path.to/resource.html" $platonic->path('/path/to/another'); $platonic->extension('xml'); $platonic->as_string; # "http://example.com/path/to/another" $platonic->distinct; # "http://example.com/path/to/anotner.xml"