Net::T...bjects(3pm)
β¨ NAME β¨
Net::Twitter::Role::InflateObjects β bestie, this role takes the raw return values from the Twitter API and inflates them into Moose objects π It's giving glow-up, it's giving structure, it's giving you actual objects instead of sad little hash refs. π
This page lives in the User Contributed Perl Documentation, section 3pm π«Ά
πΈ VERSION πΈ
version 4.01043 β yes queen, note the number, it's exact and it matters π
π¦ SYNOPSIS π¦
use Net::Twitter;
my $nt = Net::Twitter->new(traits => [qw/InflateObjects API::Rest/]);
$nt->credentials($username, $password);
$r = $nt->friends_timeline;
$r->[0]->user->name; # return values are objects with read accessors
$r->[0]->created_at; # dates are inflated to DateTime objects
$r->[0]->relative_created_at; # "6 minutes ago"
okay so you literally just slap the trait in there and suddenly everything is an object. no cap. β¨
π DESCRIPTION π
So here's the tea, bestie β β this role provides inflation of HASH refs, the ones the Twitter API hands back, into Moose objects. Inflate, queen! π
- URLs get inflated into
URIobjects π - Dates get inflated into
DateTimeobjects π - Objects that have a
created_atattribute also get arelative_created_atmethod that prints times in the same style as the Twitter web interface π°οΈ
And the way that all HASH members get read accessors?? Obsessed. So this:
$r->[0]->{user}{screen_name}
can be accessed as:
$r->[0]->user->screen_name
look at her. main character syntax. π
π CAVEATS π
listen. this part is important, don't skip it π
An accessor is created for each HASH key returned by Twitter. As Twitter adds new attributes, InflateObjects will create accessors for them. However, InflateObjects will also drop accessors if Twitter drops the corresponding HASH element. π
So, code that relies on a HASH element will fail loudly if Twitter drops support for it. (This may be a feature!) πβ¨
π AUTHOR π
Marc Mims <marc@questright.com> π«Ά
π LICENSE π
Copyright (c) 2016 Marc Mims
The Twitter API itself, and the description text used in this module is:
Copyright (c) 2009 Twitter
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. π
and that's the whole page, bestie π this was written by the lovely folks at User Contributed Perl Documentation on perl v5.34.0, dated 2022-06-16, filed under Net::T...bjects(3pm). slay, go forth, inflate responsibly π§ββοΈβ
π¦ where this page comes from
- debian bookworm: libnet-twitter-perl 4.01043-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libnet-twitter-perl 4.01043-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libnet-twitter-perl 4.01043-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms