Questions tagged [moops]

Moops is a meta-framework for object-oriented programming in the Perl programming language.

Moops is a meta-framework for object-oriented programming in the Perl programming language.

11 questions
11
votes
1 answer

Moops lexical_has and default values

I am trying to understand how lexical_has attributes work in Moops. This feature comes from Lexical::Accessor and, as I understand it, the lexical_has function is able to generate a CODE reference to any attribute a class might "lexically have" by…
G. Cito
  • 6,210
  • 3
  • 29
  • 42
8
votes
2 answers

ctags support for moops

Moops enhances the perl syntax by constructs such as: class MyPkg::MyClass { # ... } and adds the possibility to declare signatures for member functions by introducing the new keywords fun and method: class MyPkg::MyClass { method…
sschober
  • 2,003
  • 3
  • 24
  • 38
6
votes
1 answer

Can I instantiate an object in Dancer to return a value to display?

I have the following code in my Dancer app module: package Deadlands; use Dancer ':syntax'; use Dice; our $VERSION = '0.1'; get '/' => sub { my ($dieQty, $dieType); $dieQty = param('dieQty'); $dieType = param('dieType'); if…
BackPacker777
  • 673
  • 2
  • 6
  • 21
3
votes
1 answer

How can I overload methods in Moops?

I would like to overload some methods in Moops. I have the tried the following code: method setIdNum() { print "Please enter ID number: "; chomp (my $input = ); $self->$idNum($input); } method setIdNum(Int $num) { …
BackPacker777
  • 673
  • 2
  • 6
  • 21
3
votes
1 answer

Import functions/subroutine into subclass

I'm using Moops and I'd like something like this to work: use Moops; class A { fun f { print "yay,f!\n"; } } class B extends A { fun g { f(); } } B->g(); # should print 'yay, f!' Instead this yields: Undefined subroutine &B::f…
sschober
  • 2,003
  • 3
  • 24
  • 38
2
votes
1 answer

Use MooseX meta attributes with Moops

Is it possible to use MooseX meta attributes with Moops? Consider this Moose sample code: use v5.14; use strict; use warnings; package TraitTest; use Moose; with 'MooseX::Getopt'; has opt1 => ( traits => ['Getopt'], is => 'ro', isa =>…
sschober
  • 2,003
  • 3
  • 24
  • 38
1
vote
1 answer

Can someone please explain how to implement and utilize privately-scoped arrays in Moops?

I am trying to learn Moops and I can't quite grasp how to use populate and iterate over lexical_has arrayRefs. Can you demonstrate their usage here with code please? I wrote the following: lexical_has people => (is => 'rw', …
BackPacker777
  • 673
  • 2
  • 6
  • 21
1
vote
2 answers

class_has for Moops

Is there something like MooseX::ClassAttribute for Moops? Note, that I want static/class attributes using the Moo backend, as I do not want to bring in the Moose backend.
sschober
  • 2,003
  • 3
  • 24
  • 38
1
vote
1 answer

Attribute accessor not satisfying role requirement when using Moops and Moose

Consider the following code sample: use Moops; role RoleA using Moose { requires 'm1'; method m2() { $self->m1." World!\n"; } } role RoleB using Moose { has 'm1' => ( accessor => 'm1', is => 'ro', isa => 'Str', default =>…
sschober
  • 2,003
  • 3
  • 24
  • 38
0
votes
1 answer

Changing writer prefix when (is => “rwp”)

If I want to change write protected attribute ie. use Moops; class foo { has attr => (is => "rwp"); } one have to use _set_attr(). Is it possible to change that to _attr() without using explicit writer? Tried use MooseX::::AttributeShortcuts…
mpapec
  • 50,217
  • 8
  • 67
  • 127
0
votes
1 answer

Generic tracing mock class

I am trying to construct a convenient mocking class using moops: #!/usr/bin/env perl use Modern::Perl '2014'; use Moops; use Test::More; class aClass { method m {} method l {} }; class NotWorkingMockAClass extends aClass { has methodCallLog…
sschober
  • 2,003
  • 3
  • 24
  • 38