Created
May 8, 2010 04:41
-
-
Save sneakin/394342 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Doc | |
class Base | |
def read; end | |
def destroy!; end | |
end | |
class File < Base | |
# operates on a file | |
end | |
class DestroyedDoc < Base | |
# raises errors | |
end | |
class Proxy < Base | |
def initialize(doc) | |
@doc = doc | |
end | |
def destroy! | |
@doc.destroy! | |
@doc = Doc::DestroyedDoc.new(path) | |
end | |
def read | |
@doc.read | |
end | |
end | |
def self.open(path) | |
Doc::Proxy.new(Doc::File.new(path)) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment