|
| 1 | +=begin pod :kind<Type> :subkind<role> :category<metamodel> |
| 2 | +
|
| 3 | +=TITLE role Metamodel::Versioning |
| 4 | +
|
| 5 | +=SUBTITLE Metaobjects that support versioning |
| 6 | +
|
| 7 | + role Metamodel::Versioning { ... } |
| 8 | +
|
| 9 | +L<Metamodel|/language/mop> role for (optionally) versioning metaobjects. |
| 10 | +
|
| 11 | +When you declare a type, you can pass it a version, author, and/or API and get |
| 12 | +them, like so: |
| 13 | +
|
| 14 | +=begin code :lang<perl6> |
| 15 | +class Versioned:ver<0.0.1>:auth<github:Kaiepi>:api<1> { } |
| 16 | +
|
| 17 | +say Versioned.^ver; # OUTPUT: «v0.0.1» |
| 18 | +say Versioned.^auth; # OUTPUT: «github:Kaiepi» |
| 19 | +say Versioned.^api; # OUTPUT: «1» |
| 20 | +=end code |
| 21 | +
|
| 22 | +This is roughly equivalent to the following, which also sets them explicitly: |
| 23 | +
|
| 24 | +=begin code :lang<perl6> |
| 25 | +BEGIN { |
| 26 | + class Versioned { } |
| 27 | + Versioned.^set_ver: v0.0.1; |
| 28 | + Versioned.^set_auth: 'github:Kaiepi'; |
| 29 | + Versioned.^set_api: <1>; |
| 30 | +} |
| 31 | +
|
| 32 | +say Versioned.^ver; # OUTPUT: «v0.0.1» |
| 33 | +say Versioned.^auth; # OUTPUT: «github:Kaiepi» |
| 34 | +say Versioned.^api; # OUTPUT: «1» |
| 35 | +=end code |
| 36 | +
|
| 37 | +=head1 Methods |
| 38 | +
|
| 39 | +=head2 method ver |
| 40 | +
|
| 41 | + method ver($obj) |
| 42 | +
|
| 43 | +Returns the version of the metaobject, if any, otherwise returns L<Mu|/type/Mu>. |
| 44 | +
|
| 45 | +=head2 method auth |
| 46 | +
|
| 47 | + method auth($obj) |
| 48 | +
|
| 49 | +Returns the author of the metaobject, if any, otherwise returns an empty string. |
| 50 | +
|
| 51 | +=head2 method api |
| 52 | +
|
| 53 | + method api($obj) |
| 54 | +
|
| 55 | +Returns the API of the metaobject, if any, otherwise returns an empty string. |
| 56 | +
|
| 57 | +=head2 method set_ver |
| 58 | +
|
| 59 | + method set_ver($obj, $ver) |
| 60 | +
|
| 61 | +Sets the version of the metaobject. |
| 62 | +
|
| 63 | +=head2 method set_auth |
| 64 | +
|
| 65 | + method set_auth($obj, $auth) |
| 66 | +
|
| 67 | +Sets the author of the metaobject. |
| 68 | +
|
| 69 | +=head2 method set_api |
| 70 | +
|
| 71 | + method set_api($obj, $api) |
| 72 | +
|
| 73 | +Sets the API of the metaobject. |
| 74 | +
|
| 75 | +=end pod |
0 commit comments