active_decorator icon indicating copy to clipboard operation
active_decorator copied to clipboard

If no decorator is found, fall back to decorators for parent classes

Open johanlindblad opened this issue 12 years ago • 2 comments

I use single table inheritance quite a lot so I made this in order to avoid having to create a decorator for every single child class if all I need is common functionality.

With this change, a class Child that inherits from Parent will be decorated with ParentDecorator if no ChildDecorator exists.

I considered making it so that both ChildDecorator and ParentDecorator would be included of both exist but I am not sure if that is a good idea. Now I just include ParentDecorator in my ChildDecorator manually which works just fine.

johanlindblad avatar Mar 24 '13 19:03 johanlindblad

+1

I want to do the same thing, too.

I have other idea that Child has class method decorator(mod). For example.

class Parent < ActiveRecord::Base
end

class Child < Parent
  decorator ParentDecorator
end

module ParentDecorator
  def name
    link_to name, parent_path
  end
end

joker1007 avatar May 17 '13 04:05 joker1007

any advance on this, how can I decorate a STI models (parent and childs), how is the folder structure?

rderoldan1 avatar Apr 21 '14 20:04 rderoldan1