in reply to is my api wrapper abstraction ok (is it perlish?)
You are not calling your anonymous subs as methods, thus they don't get any invocant ($self). You could call them like this:
my $method = $a->answers->{answers_comments}; $a->answers->$method( 123, 134, 145, { order => "desc", sort => "votes", }, );
Then they'll have an invocant.
It would be much saner though to install your methods as genuine methods, not coderefs floating around attached to blessed objects.
# in Answers.pm use Sub::Name 'subname'; *answers_comments = subname( "Net::StackExchange::V2::Answer::answers_comments", one_param("answers","comments"), );
Now you can call it like a proper method:
$a->answers->answers_comments( 123, 134, 145, { order => "desc", sort => "votes", }, );
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: is my api wrapper abstraction ok (is it perlish?)
by gideondsouza (Pilgrim) on Jan 19, 2013 at 10:25 UTC | |
by tobyink (Canon) on Jan 19, 2013 at 11:24 UTC | |
by gideondsouza (Pilgrim) on Jan 19, 2013 at 13:51 UTC | |
by tobyink (Canon) on Jan 19, 2013 at 18:45 UTC | |
by gideondsouza (Pilgrim) on Jan 20, 2013 at 05:25 UTC | |
by Anonymous Monk on Jan 19, 2013 at 11:12 UTC |
In Section
Seekers of Perl Wisdom