Skip to content

Instantly share code, notes, and snippets.

@nkallen
Forked from patmaddox/blah.rb
Created May 28, 2009 03:11
Show Gist options
  • Save nkallen/119068 to your computer and use it in GitHub Desktop.
Save nkallen/119068 to your computer and use it in GitHub Desktop.
# This comes from GenericWebLibrary
class BaseComponent
end
# This comes from RestExtensionLibrary
class RestComponent < BaseComponent
end
# In a language with mixins you could do
class SomeFilterStuff
def initialize(base_component)...
def login_required...
def method_missing(...)
base_component.send(...
end
end
SomeFilterStuff.new(BaseComponent.new)
SomeFilterStuff.new(RestComponent.new)
# not more verbose and you've replaced a static decoration with a dynamic decoration. which is always preferable, since you can change the order, add more decorations, etc. at runtime.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment