-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
=begin pod :kind<Type> :subkind<role> :category<metamodel> | ||
=TITLE role Metamodel::Versioning | ||
=SUBTITLE Metaobjects that support versioning | ||
role Metamodel::Versioning { ... } | ||
L<Metamodel|/language/mop> role for (optionally) versioning metaobjects. | ||
When you declare a type, you can pass it a version, author, and/or API and get | ||
them, like so: | ||
=begin code :lang<perl6> | ||
class Versioned:ver<0.0.1>:auth<github:Kaiepi>:api<0> { } | ||
say Versioned.^ver; # OUTPUT: «0.0.1» | ||
say Versioned.^auth: # OUTPUT: «github:Kaiepi» | ||
say Versioned.^api: # OUTPUT: «0» | ||
=end code | ||
This is roughly equivalent to the following, which also sets them explicitly: | ||
=begin code :lang<perl6> | ||
BEGIN { | ||
class Versioned { } | ||
Versioned.^set_ver: '0,0,1'; | ||
Versioned.^set_auth: 'github:Kaiepi'; | ||
Versioned.^set_api: IntStr.new: 0, '0'; | ||
} | ||
say Versioned.^ver; # OUTPUT: «0.0.1» | ||
say Versioned.^auth: # OUTPUT: «github:Kaiepi» | ||
say Versioned.^api: # OUTPUT: «0» | ||
=end code | ||
=head1 Methods | ||
=head2 method ver | ||
method ver($obj) | ||
Returns the version of the metaobject, if any, otherwise returns L<Mu|/type/Mu>. | ||
=head2 method auth | ||
method auth($obj) | ||
Returns the author of the metaobject, if any, otherwise returns an empty string. | ||
=head2 method api | ||
method api($obj) | ||
Returns the API of the metaobject, if any, otherwise returns an empty string. | ||
=head2 method set_ver | ||
method set_ver($obj, $ver) | ||
Sets the version of the metaobject. | ||
=head2 method set_auth | ||
method set_auth($obj, $auth) | ||
Sets the author of the metaobject. | ||
=head2 method set_api | ||
method set_api($obj, $api) | ||
Sets the API of the metaobject. | ||
=end pod |