nkallen (owner)

Fork Of

Revisions

gist: 119068 Download_button fork
public
Public Clone URL: git://gist.github.com/119068.git
blah.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 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.