Skip to content

Instantly share code, notes, and snippets.

@vladiim
Created May 19, 2012 00:28
Show Gist options
  • Select an option

  • Save vladiim/2728304 to your computer and use it in GitHub Desktop.

Select an option

Save vladiim/2728304 to your computer and use it in GitHub Desktop.
module Decorator
def initialize(component)
@component = component
end
def method_missing(meth, *args)
if @component.respond_to? meth
@component.send(meth, *args)
else
super
end
end
def respond_to?(meth)
@component.respond_to? meth
end
module Factory
# `decorate` wraps classes in a decorator
def decorate(klass, component)
klass = Object.const_get(klass)
klass_source(klass).call(component)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment