Mock::...ontrol(3pm)

πŸ“¦
version 1.111 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Mock::Quick::Object::Control(3pm) πŸ’–

okay bestie, so this is the manual page for Mock::Quick::Object::Control β€” like, the control half of the Mock::Quick::Object situation. It lives in the User Contributed Perl Documentation corner of the internet, and yes, the title really is abbreviated with dots like Mock::...ontrol(3pm) because manpage headers are dramatic like that. πŸŽ€


✨ NAME ✨

Mock::Quick::Object::Control β€” the whole vibe is: you control a mocked object after it's already been created. that's it, that's the job. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

Control a mocked object after creation. fr fr, that's the entire description. it's giving "short and iconic." πŸ‘‘


🌸 SYNOPSIS 🌸

here's the tea, copied exactly so you don't break anything:

my $obj = Mock::Quick::Object->new( ... );
my $control = Mock::Quick::Object::Control->new( $obj );

$control->set_methods( foo => sub { 'foo' });
$control->set_attributes( bar => 'baz' );

# Make an attribute exist so that it can be used for get/set operations.
$control->set_attributes( empty => undef );

see that last bit? setting an attribute to undef is how you make it exist so it can actually be used for get/set operations. not me learning that the hard way 😭


πŸ’œ METHODS πŸ’œ

okay so here's every single one, no skips, no cap:

  • $control = $CLASS->new( $obj ) β€” the constructor, bestie. hand it your $obj and it hands you back a $control. 🫢
  • $control->set_methods( name => sub { ... }, ... ) β€” Set/Create methods. you pass name-and-coderef pairs and boom, methods exist now. ⭐
  • $control->set_attributes( name => $val, ... ) β€” Set/Create attributes (simple get/set accessors). the most basic accessor energy, and honestly? we love her. πŸŽ€
  • $control->clear( $name1, $name2, ... ) β€” Remove attributes/methods. yeet them by name. 🧚
  • $control->strict( $BOOL ) β€” Enable/Disable strict mode. you pass a $BOOL, so 1/0 vibes, and strict mode turns on or off accordingly. πŸ”₯
  • $data = $control->metrics() β€” Returns a hash where keys are method names, and values are the number of times the method has been called. When a method is altered or removed the key is deleted. so it's like a little call counter for your mocks, and if you touch the method the count just disappears. main character behavior honestly πŸ’€

🌈 AUTHORS 🌈

Chad Granum exodist7@gmail.com

shoutout to Chad, absolute legend 🫑


Copyright (C) 2011 Chad Granum

Mock-Quick is free software; Standard perl licence.

Mock-Quick is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.

not me putting the ALL-CAPS bits in bold because they're legally doing the most πŸ’€ no warranty, bestie, that part is real.

okay that's the whole page!! it's from perl v5.34.0, dated 2022-06-15, and it's filed under Mock::...ontrol(3pm) in the User Contributed Perl Documentation. go forth and control your mocks, queen πŸŒΈβœ¨πŸ¦‹

πŸ“¦ where this page comes from