Open wdrexler opened 10 years ago
So current theory is that while this fails...
RubySpeech::GRXML.draw root: 'root', tag_format: 'semantics/1.0' do
rule id: 'root', scope: 'public' do
item { my_method }
end
end
...this would work...
RubySpeech::GRXML.draw root: 'root', tag_format: 'semantics/1.0' do
item { my_method }
end
The existing test for this needs to be extended to cover invocation in a nested block.
So I've written a new test that covers invocation in a nested block. It fails, as expected. How would we fix this, @benlangfeld?
First off, submit the spec as a pull request to replace this issue (or convert this one).
As for a fix, either recursively walk up the tree in method_missing or directly grab the block context from the root of the tree. The latter is more efficient but the former more closely respects normal closure binding semantics. Thoughts?
So I'm leaning towards walking up the tree instead of just grabbing the root element. Without knowing the actual performance impact of grabbing the block context of the root element (in, say, an Adhearsion app, is walking up the tree really going to be a bottleneck?), I'd say that we're better off going with the more semantically valid approach.
Go for it :)
It seems that when there is a method inside a class that returns a grammar, and that grammar uses the return values of other methods inside the class, RubySpeech throws an error.
Code looks like this: https://gist.github.com/wdrexler/f0b229d7dfb7a9629dbe The error returned is:
This error does not occur when either:
RubySpeech::GRXML.draw
block startsThis was tested against latest develop.