If no decorator is found, fall back to decorators for parent classes
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.
+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
any advance on this, how can I decorate a STI models (parent and childs), how is the folder structure?