RubyFlow The Ruby and Rails community linklog


The Ruby and Rails community linklog

Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!

Super simple ruby decorators

I wanted to have model decorators, accessible from anywhere but in separate namespace.


if somebody uses or something similar I would appreciate comment when and why alternate approach better, if it is.

I personally prefer plain old decorators:

— No magic thus no bugs — Easy to test — We can have number of decorators for different purposes

One thing I found lacking with various decorator implementations is that they always fall back to method missing for every method call.

The following example attempts optimizes the class by defining the method the first time method missing is called for a method that the decorated object responds to.

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in