UR::Ob...t::Text(3pm)
β¨ UR::Object::View::Default::Text β¨
okay so bestie, this is a page from the User Contributed Perl Documentation collection, and the whole thing is literally just UR::Object::View::Default::Text β object views, but make them text. π
π NAME π
UR::Object::View::Default::Text β object views in text format. that's it, that's the whole vibe. π¦
πΈ SYNOPSIS πΈ
watch this, it's giving elegant:
$o = Acme::Product->get(1234);
# generates a UR::Object::View::Default::Text object:
$v = $o->create_view(
toolkit => 'text',
aspects => [
'id',
'name',
'qty_on_hand',
'outstanding_orders' => [
'id',
'status',
'customer' => [
'id',
'name',
]
],
],
);
$txt1 = $v->content;
$o->qty_on_hand(200);
$txt2 = $v->content;
so you grab an object, you build a view with toolkit => 'text' and a whole lil nested list of aspects, you ask it for $v->content, you poke the object with $o->qty_on_hand(200), and then $v->content again gives you fresh text. the view stays live, no cap. π₯
π DESCRIPTION π
This class implements basic text views of objects. It is used for command-line tools, and it is the base class for other specific text formats like XML, HTML, JSON, etc. so basically it's the main character and everything else is a spin-off. π
π¦ WRITING A SUBCLASS π¦
want your own flavor? it's giving inherit and slay:
# In Acme/Product/View/OutstandingOrders/Text.pm
package Acme::Product::View::OutstandingOrders::Text;
use UR;
class Acme::Product::View::OutstandingOrders::Text {
is => 'UR::Object::View::Default::Text'
};
sub _initial_aspects {
return (
'id',
'name',
'qty_on_hand',
'outstanding_orders' => [
'id',
'status',
'customer' => [
'id',
'name',
]
],
);
}
$v = $o->create_view(perspective => 'outstanding orders', toolkit => 'text');
print $v->content;
you set is => 'UR::Object::View::Default::Text', you override _initial_aspects with your own list of aspects, and then you just create_view(perspective => 'outstanding orders', toolkit => 'text') and print $v->content. iconic. periodt. π
β¨
β SEE ALSO β
UR::Object::ViewUR::Object::View::Toolkit::TextUR::Object
go read those next, iykyk π«Ά
and that's the whole page bestie, no crumbs left π
this little tour was brought to you by perl v5.32.1, dated 2022-01-17 π bye bye, go build some text views, you're doing amazing sweetie ππ§
π¦ where this page comes from
- debian bookworm: libur-perl 0.470+ds-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libur-perl 0.470+ds-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libur-perl 0.470+ds-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