Skip to content
Browse files

Revert "Use Mo instead of Moo and ship it"

This reverts commit 535e7d9.
  • Loading branch information...
1 parent d09a966 commit 08c39cef19e6aa002dbef7f96a4ebb6388d354ea @tadzik committed
Showing with 12 additions and 53 deletions.
  1. +0 −37 lib/Mo.pm
  2. +12 −16 lib/Quiz.pm
View
37 lib/Mo.pm
@@ -1,37 +0,0 @@
-use 5.010;
-package Mo;
-use strict;
-use warnings;
-
-our $VERSION = '0.11';
-
-use base 'Exporter';
-
-our @EXPORT = qw(extends has);
-
-sub import {
- my $class = $_[0];
- strict->import;
- warnings->import;
- no strict 'refs';
- push @{caller.'::ISA'}, $class;
- goto &Exporter::import;
-}
-
-sub new {
- my $class = shift;
- my $self = bless {@_}, $class;
- if ($self->can('BUILD')) { $self->BUILD }
- return $self;
-}
-
-no strict 'refs';
-
-sub has {
- my $name = shift;
- *{caller."::$name"} = sub { @_-1 ? $_[0]->{$name} = $_[1] : $_[0]->{$name} };
-}
-
-sub extends { @{caller.'::ISA'} = $_[0] }
-
-1;
View
28 lib/Quiz.pm
@@ -6,29 +6,25 @@
use JSON::XS;
use File::Slurp 'slurp';
- use Mo;
- has 'db';
- has 'states'; # int -> id pytania
- has 'questions'; # id pytania -> obiekt Question
- has 'answers';
+ use Moo;
+ has db => (is => 'ro', default => sub { 'db.json' });
+ # int -> id pytania
+ has states => (is => 'ro', default => sub { [] });
+ # id pytania -> obiekt Question
+ has questions => (is => 'ro', default => sub { {} });
+ has answers => (is => 'ro', default => sub { {} });
{
package Question;
- use Mo;
- has 'state';
- has 'question';
- has 'yes';
- has 'no';
+ use Moo;
+ has state => ( is => 'ro' );
+ has question => ( is => 'ro' );
+ has yes => ( is => 'ro' );
+ has no => ( is => 'ro' );
}
sub BUILD {
my $self = shift;
- # defaults
- $self->db // $self->db('db.json');
- $self->states([]);
- $self->questions({});
- $self->answers({});
-
my $data = decode_json(slurp($self->db));
my $stateiter = 1;

0 comments on commit 08c39ce

Please sign in to comment.
Something went wrong with that request. Please try again.