ddengler / prawn-grouping

A gem to add a more flexible grouping option to the prawn gem
https://github.com/ddengler/prawn-grouping
MIT License
14 stars 21 forks source link

NoMethodError results from calling a non-Prawn method inside group block #3

Closed serra-allgood closed 10 years ago

serra-allgood commented 10 years ago

This particular use case involves a class inheriting from Prawn::Document. Because prawn-grouping creates a shallow copy of the document to test if the block spills over to a new context, the subclass's methods are not available in the group block, resulting in a NoMethodError if they're called inside of it.

serra-allgood commented 10 years ago

The solution for this issue is to use the Prawn::Document.extensions API as much as possible. In my own use case, I was able to extract much of the subclass to a module that's loaded with Prawn::Document.extensions << MyModule inside an initializer for my Rails project. Due to the particularities of my use case, I still needed the subclass to inherit from Prawn::Document, but the group block no longer gets upset about those custom methods.

ddengler commented 10 years ago

@corwinkelly Thanks for the update on this.