Questions tagged [method-modifier]

26 questions
12
votes
1 answer

In Perl/Moose, how can I apply a modifier to a method in all subclasses?

I have a Moose class that is intended to be subclassed, and every subclass has to implement an "execute" method. However, I would like to put apply a method modifier to the execute method in my class, so that it applies to the execute method in all…
Ryan C. Thompson
  • 40,856
  • 28
  • 97
  • 159
4
votes
3 answers

How can I apply a method modifier to a method generated by AUTOLOAD?

I have a very interesting predicament. I am working on a Perl script interface to the CVS repository and have created Perl Objects to represent Modules,Paths, and Files. Since Modules, Paths, and Files can all have CVS commands issued on them, I…
tjwrona1992
  • 8,614
  • 8
  • 35
  • 98
3
votes
2 answers

Javascript console output before and after method call with AOP

I would like to measure the computing time of methods. A nice way is (How do you performance test JavaScript code?) with console.time('Function #1'); and console.timeEnd('Function #1'); My idea is to add these console outputs on…
3
votes
2 answers

Why doesn't Moose role application with method modifiers work in my code?

I have a Role and several classes that mix-in the role. The Role class loads all of the implementing classes so that anything that imports Blah can use them without typing a lot of 'use' lines. package Blah; use Moose::Role; use Blah::A; use…
rjh
  • 49,276
  • 4
  • 56
  • 63
3
votes
2 answers

Moose method modifiers in base class don't get called

It's cool that it's possible to add them in sub classes or mix them in in roles. My problem is that it seems method modifiers from the base class get deactivated when subclasses redefine the method itself (not the modifier). Maybe I'm understanding…
memowe
  • 2,656
  • 16
  • 25
2
votes
4 answers

Java 9 Interface : Why default Modifier Converted into public Modifier

My Question is about interface. I create an interface and define four methods: first method is a private method; second is a default method; third is a static method; and fourth is an abstract method. After compiling this interface and checking its…
Ng Sharma
  • 2,072
  • 8
  • 27
  • 49
2
votes
3 answers

Can I order order method modifiers loaded as part of traits?

This is a follow up to a previous question. if I have multiple plugins/traits with around modifiers, is it possible to ensure a certain execution order (seeing as how I can't be sure which will actually get loaded)? or can I really only control that…
xenoterracide
  • 16,274
  • 24
  • 118
  • 243
2
votes
1 answer

Enhance function prototype to call a given function before execution itself

I want to do an AOP-like 'before' functionality for JavaScript functions. So I looked for existing solution and found the aop-plugin for jQuery. Unfortunately the plugin simply wraps the given function. So any object that points to the original…
2
votes
2 answers

Moose Perl: "modify multiple methods in all subclasses"

I have a Moose BaseDBModel which has different subclasses mapping to my tables in the database. All the methods in the subclasses are like "get_xxx" or "update_xxx" which refers to the different DB operations. Now i want to implement a cache system…
1
vote
2 answers

Moose around method modifier, setter and constructor (new): intercept all updates to an attribute

Update The code I posted in my original question was illustrative of the way method modifier do or don't work. It was not necessarily illustrative of the problem description I gave. This code should be. It works, but contains a hack in the trigger I…
Lumi
  • 14,775
  • 8
  • 59
  • 92
1
vote
1 answer

Can i add method after method being executed meld aop

Consider I have class function home {}{ this.door=function(){}, this.tiles=function(){} } I have to add some message after it's methods are called using this library called meld js…
jsduniya
  • 2,464
  • 7
  • 30
  • 45
1
vote
1 answer

What's the purpose for the variable `tmp` in this snippet?

I'm having troubling understanding the point of the variable tmp in the following code: $.extend($.Widget.prototype, { yield: null, returnValues: { }, before: function(method, f) { var original = this[method]; …
Jinghui Niu
  • 990
  • 11
  • 28
1
vote
2 answers

fail to override setter & getter of window.location

I want to change all links assigned to window.location. So I assume location has getter & setter . That's why i cloned it & then i override the real window.location : var clonedLocation=Object.assign({},window.location); …
Abdennour TOUMI
  • 87,526
  • 38
  • 249
  • 254
1
vote
11 answers

Add function into the scope of another function JavaScript

I'm trying to get the example code below to work. Edit (Trying to be more clear what the aim is): I wan't to make all the functions and variables of the obj available in the functions setup and draw as they where globals. This is not for the…
fabianmoronzirfas
  • 4,091
  • 4
  • 24
  • 41
1
vote
2 answers

Pass variables around the around method modifier

Is it possible to pass variables between multiple calls to the around MethodModier? example (that doesn't work but hopefully conveys what I want to do) sub mysub { ... }; around 'mysub' => sub { my $orig = shift; my $self = shift; my…
xenoterracide
  • 16,274
  • 24
  • 118
  • 243
1
2