Skip to content

Instantly share code, notes, and snippets.

@pedro-vasconcelos
Created December 8, 2012 19:07
Show Gist options
  • Save pedro-vasconcelos/4241442 to your computer and use it in GitHub Desktop.
Save pedro-vasconcelos/4241442 to your computer and use it in GitHub Desktop.
Abstract Factory Pattern
class Report
def output
formatter_class =
begin
@format.to_s.classify.constantize
rescue NameError
# ...handle 'invalid formatter type'
end
formatter = formatter_class.send(:new, self)
# etc
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment