prawnpdf/prawn — pull request #662 by packetmonkey (2014-02-04 03:00:23+00:00)
Title: Allow prawn to #draw an encapsulated component.

This PR gives Prawn::Document a `#draw` method that accepts an object and a list of arguments. Prawn will then in turn pass itself and those arguments to the `#call` method on that object. This gives us a clean standard for bundling and encapsulating behavior we want to add to a prawn document.

Take this simple example

```ruby
class CaptionedImage
def self.call document, *options
document.image options[:image]
document.text options[:text]
end
end

doc = Prawn::Document.new
doc.draw CaptionedImage, image: "red_wings.jpg", "Detroit winning another hard earned Stanley Cup"
```

This could be expanded for more complex examples but I think it makes the point. I'm not 100% sold on the use of `#draw` for the method name but I think it's probably good enough. This method is also the core functionality needed to provide a possibly prettier way for prawn plugin authors to distribute their additional features as well.

What does everyone think?