Skip to content

Instantly share code, notes, and snippets.

@practicingruby
Created February 15, 2012 16:29
Show Gist options
  • Select an option

  • Save practicingruby/1837078 to your computer and use it in GitHub Desktop.

Select an option

Save practicingruby/1837078 to your computer and use it in GitHub Desktop.
module Prawn
class Drawing
# should work as a drop-in, as all of this
# stuff will proxy to Document
include Prawn::Graphics
def initialize(document)
self.document = document
end
def method_missing(id, *a, &b)
document.send(id, *a, &b)
end
private
attr_accessor :document
end
class Document
extend Forwardable
# this makes the semver features clear
delegates [:stroke, :fill, :line, ...] => :drawing
def initialize(*a, &b)
self.drawing = Prawn::Drawing.new
end
private
attr_accessor :drawing
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment