Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warnings with Moose 2.2004 #70

Closed
karenetheridge opened this issue Feb 6, 2017 · 2 comments
Closed

warnings with Moose 2.2004 #70

karenetheridge opened this issue Feb 6, 2017 · 2 comments

Comments

@karenetheridge
Copy link
Contributor

karenetheridge commented Feb 6, 2017

The latest Moose now contains more checks for overwriting internal methods, and now Net::Twitter warns...

(newlines added for readability)

perl -MNet::Twitter -wle'print Net::Twitter->new(traits => ["API::RESTv1_1", "OAuth"], consumer_key => 123, consumer_secret => 456, ssl => 1)'
You are overwriting a accessor (request_token_url) for the request_token_url attribute
(defined at .../Net/Twitter/Role/OAuth.pm line 43) with a new reader method for the
request_token_url attribute (defined at .../Net/Twitter/Role/OAuth.pm line 43) at
.../Moose/Meta/Attribute.pm line 1096, <DATA> line 1.
@karenetheridge
Copy link
Contributor Author

karenetheridge commented Feb 6, 2017

This could be solved (albeit by making these attribute accesses a bit slower)
with this patch to Net/Twitter/Role/OAuth.pm:

  # url attributes
  for my $attribute ( qw/authentication_url authorization_url request_token_url access_token_url xauth_url/ ) {
      has $attribute => (
          isa    => 'Str', is => 'rw', required => 1,
-         # inflate urls to URI objects when read
-         reader => { $attribute => sub { URI->new(shift->{$attribute}) } },
      );
+      # inflate urls to URI objects when read
+      around $attribute => sub {
+          my ($orig, $self) = (shift, shift);
+          return @_ ? $self->$orig(@_) : URI->new($self->$orig);
+      };
  }

@karenetheridge
Copy link
Contributor Author

@perigrin points out that if you were overwriting the reader like that before, htf could the writer ever work? you're replacing it with a read-only version.

Do these attributes really need to be writable? is this tested anywhere?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant