Commit Graph

2 Commits

Author SHA1 Message Date
R. Tyler Croy eb4df666fc Initial cut of the "define" API with blocks
This has taken a lot of experimenting and research to get to, and it has to
resort to clever method_missing hacks because it appears to be absolutely
impossible to take a binding from a block and mutate it.

Original appraoch looked something like this:

    define :log, message: String do with
        # ... logic
    end

The `with` method couldn't access the right caller's binding (using clever
hacks: <http://rubychallenger.blogspot.com/2011/07/caller-binding.html>)

A follow up approach:

    define :log, message: String do with binding
        # ... logic
    end

Wouldn't work because the binding object ID inside the block would change as
soon as the with method would mutata it.

Thus the current approach, which is probably not going to perform worth a shit
2014-10-24 01:00:14 -07:00
R. Tyler Croy eb520763cd Initial commit 2014-10-23 18:22:11 -07:00