Injections / Extensions
Reported by Dan Schultz | January 21st, 2011 @ 09:33 AM
Here's an idea for injecting methods into dynamic objects.
Create an Injector
class that injects a closure into
an object's prototype property.
Injects could be defined at the class level:
package currency
{
public class Money extends Object
{
private var _value:Number;
public function Money(value:Number)
{
_value = value;
}
}
}
public class Currency
{
Extension.inject(Number, "dollars", function():Money
{
return new Money(this);
});
}
express(Currency);
// if non-strict:
var amount:Money = (5).dollars();
// strict requires a cast to object:
amount = (5 as Object).dollars();
Comments and changes to this ticket
-
Dan Schultz January 21st, 2011 @ 09:34 AM
- Tag set to feature, idea
-
Dan Schultz January 21st, 2011 @ 09:42 AM
- Milestone set to 0.2.0
- Milestone order changed from 1 to 0
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
Mesh is an open-source persistence framework for Adobe Flex. It is designed to make the persistence of your application's model easier. Mesh provides the mechanisms for defining the associations between your model's entities, tracking which objects need to be saved, and mapping your entities to backend services.
<p>
<strong>Wiki</strong>
The Mesh wiki is hosted on GitHub at <a href="https://github.com/danschultz/mesh/wiki">https://github.com/danschultz/mesh/wiki</a>.
</p>
<p>
<strong>Source Code</strong>
Mesh is hosted on GitHub at <a href="http://github.com/danschultz/mesh">http://github.com/danschultz/mesh</a>.
</p>