API-Docker
view release on metacpan or search on metacpan
.claude/skills/getty-perl-core/SKILL.md view on Meta::CPAN
- **Classes:** `Moo`, `Moose`, `Catalyst` and anything derived from them enable both on import â do not repeat them there.
The rule is "always on", never "leave them out". Omitting them from a class is correct only because the object system already did it.
## Object system
- **One object system per distribution.** Pick Moo or Moose and use it everywhere; mixing is for boundaries a framework forces (e.g. RapidApp), not a choice.
- **`is => 'ro'` is the default.** `rw` is the exception and needs a reason.
- **`lazy_build => 1` + `sub _build_foo`** over `default => sub { ... }` for anything non-trivial.
- **`weak_ref => 1`** on attributes holding a reference back to a parent/owner â standard for nested object graphs, prevents circular refs.
- **`namespace::autoclean`** on every class file. Classes extending DBIx::Class (`MooseX::NonMoose`) use **`MooseX::MarkAsMethods autoclean => 1`** instead.
- **`no Moose;` + `__PACKAGE__->meta->make_immutable;`** at the bottom of every Moose class.
- **Types:** the tendency is to type what arrives from outside â Moose's own constraints where Moose is already there, `Types::Standard` where it is not. Not every distribution needs a type system, and none needs one for every field: `getty-perl-ty...
## Singletons
- **`->instance`** for `MooseX::Singleton` / `MooX::Singleton` classes. Never `->new` on a singleton.
- **`->new`** for everything else.
## Subroutines
.claude/skills/getty-perl-moo/SKILL.md view on Meta::CPAN
warnings->import::into($target);
Moo->import::into($target);
namespace::clean->import::into($target); # after Moo, cleans stray imports
}
package App::Thing;
use My::Mooish;
has x => (is => 'ro', default => sub { 1 });
```
**Rules:** Order matters: imports â `use Moo` â `namespace::clean`. Use `namespace::autoclean` ⥠0.16 only (older versions inflate Moo classes to Moose). Use `strictures` v2 with Moo 2.
---
## Pattern 5 â Delegation via `handles`
```perl
package App::UsesCounter;
use Moo;
has counter => (
is => 'ro',
.claude/skills/getty-perl-moo/SKILL.md view on Meta::CPAN
| Legacy non-Moo parent | `FOREIGNBUILDARGS` |
| Multiple inheritance | Last resort; use `mro 'c3'` |
---
## Common Pitfalls
- `default => []` â **shared state bug**. Always `default => sub { [] }`.
- `extends 'A'; extends 'B'` â replaces, does NOT add B to A. Use `extends 'A', 'B'`.
- Imports after `use Moo::Role` are **composed into consumers** as methods.
- `namespace::autoclean` < 0.16 inflates Moo classes to Moose unexpectedly.
- `trigger` does NOT receive old value (unlike Moose).
- `Sub::HandlesVia` must be loaded *after* `use Moo`.
- `BUILD` chain is automatic; calling `SUPER::BUILD` manually breaks it.
- Never override `DESTROY`; use `DEMOLISH`.
( run in 1.113 second using v1.01-cache-2.11-cpan-54e63673c56 )