Skip to content

Instantly share code, notes, and snippets.

@Sutto
Forked from thomasfedb/decoratable.rb
Created May 12, 2011 08:53
Show Gist options
  • Select an option

  • Save Sutto/968195 to your computer and use it in GitHub Desktop.

Select an option

Save Sutto/968195 to your computer and use it in GitHub Desktop.

Revisions

  1. Sutto revised this gist May 12, 2011. 1 changed file with 5 additions and 3 deletions.
    8 changes: 5 additions & 3 deletions decoratable.rb
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,13 @@
    module Decorator
    class Decorator

    def initialize(decorated)
    @decorated = decorated
    end

    def method_missing(method, *args)
    args.empty? ? @decorated.send(method) : @decorated.send(method, args)
    def method_missing(method, *args, &blk)
    @decorated.send(method, *args, &blk)
    end

    end

    module Decoratable
  2. thomasfedb created this gist May 12, 2011.
    15 changes: 15 additions & 0 deletions decoratable.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    module Decorator
    def initialize(decorated)
    @decorated = decorated
    end

    def method_missing(method, *args)
    args.empty? ? @decorated.send(method) : @decorated.send(method, args)
    end
    end

    module Decoratable
    def with(decorator)
    decorator.new(self)
    end
    end