-
-
Save nkallen/119068 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
# 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