Ordeal::Model::Backend::Raw - Cards/decks management via raw data
my %data = (...);
my $backend = Ordeal::Model::Backend::RAw->new(data => \%data);
my $model = Ordeal::Model->new(backend => $backend);
my $card = $backend->card($card_id); # OR
$card = $model->get_card($card_id);
my $deck = $backend->deck($deck_id); # OR
$deck = $model->get_deck($deck_id);
my @deck_identifiers = $backend->decks();
This module is a simple backend for Ordeal::Model based on a data structure.
The provided data structure is a hash reference with the following structure (sketched in YAMLish shape):
- id: d3-1
data: this is face 1
- id: d3-2
data: this is face 2
- id: d3-3
data: this is face 3
- id: d3
cards: [ d3-1 d3-2 d3-3 ]
- id: loaded-d3
cards: [ d3-1 d3-2 d3-3 d3-3 ]
Cards are provided as an array of hashes; each has an identifier and identifiers must be unique (or an exception will be raised). Other parameters that are used can be seen in the documentation for Ordeal::Model::Card.
Decks are provided as an array of hashes; each has an identifier and identifiers must be unique (or an exeption will be raised). A deck must also have a cards key pointing to an array with the list of car identifiers, in the order they appear in a sorted deck.
my $card = $obj->card($id);
get a card by identifier. Returns a Ordeal::Model::Card object.
my $deck = $obj->deck($id);
get a deck by identifier.
my $decks = $obj->decks;
Get a list of all available decks (actually, their identifiers).
my $be = Ordeal::Model::Backend::Raw->new(data => \%data);
Create a new instance, based on the provided \%data hash reference.
The code leverages some experimental Perl features like signatures and postderef; for this reason, at least perl 5.20 will be needed.
Report bugs through GitHub (patches welcome) at https://github.com/polettix/Ordeal-Model.
Flavio Poletti <email@example.com>
Copyright (C) 2020 by Flavio Poletti <firstname.lastname@example.org>
This module is free software. You can redistribute it and/or modify it under the terms of the Artistic License 2.0.
This program 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.
To install Ordeal::Model, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell
For more information on module installation, please visit the detailed CPAN module installation guide.