Art-World
view release on metacpan or search on metacpan
lib/Art/World.pm view on Meta::CPAN
use 5.20.0;
use strict;
use warnings;
package Art::World {
our $VERSION = '0.19';
use Zydeco
authority => 'cpan:SMONFF',
# Predeclaration of types avoid use of quotes in args types declarations or
# signatures. See https://codeberg.org/smonff/art-world/issues/37
declare => [
'Agent',
'Artwork',
'Collector',
'Event',
'Idea',
'Place',
'Theory',
],
version => $VERSION;
use feature qw( postderef );
no warnings qw( experimental::postderef );
use Carp qw( carp cluck );
use utf8;
use Config::Tiny;
use List::Util qw( max any );
use Math::Round;
use Try::Tiny;
role Abstraction {
has discourse ( type => Str );
# TODO could be a table in the database
has file! ( type => ArrayRef[ Idea ], );
has idea! ( type => Str, is => rw, trigger => true );
has process ( type => ArrayRef );
has project ( type => Str );
has time ( type => Int );
# Here should exist all the possible interractions of Concept entities
method initiate_process {
return $self->idea;
}
method insert_to_file {}
# etc.
method _trigger_idea {
push $self->file->@*, $self->idea;
}
}
role Active {
method participate {
say "That's interesting";
}
}
role Buyer {
requires money;
multi method acquire ( Artwork $art ) {
$self->pay( $art, $self );
$art->change_owner( $self );
}
}
# Dunno how but the fact of being collected should bump artist reputation
role Collectionable {
has owner (
lazy => true,
is => rw,
clearer => true,
writer => 'set_owner',
type => ArrayRef[ Agent ]) = $self->creator;
has value ( is => rw );
has status (
enum => ['for_sale', 'sold'],
# Create a delegated method for each value in the enumeration
handles => 1,
default => 'for_sale' );
method $remove_from_seller_collection {
my $meta = Art::World::Util->new_meta;
# Removal of the to-be-sold Artwork in seller collection
for my $owner ( $self->owner->@* ) {
# Artists don't have a collection
# Or maybe they can... So we should add a specific case
if ( $meta->get_class( $owner ) !~ '^Art::World::Artist$' ) {
while ( my ( $i, $art ) = each( $owner->collection->@* )) {
# Removing if a matching artwork is found
( run in 1.653 second using v1.01-cache-2.11-cpan-6de40a662fe )