Skip to content

Conversation

@johanlindblad
Copy link

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.

@joker1007
Copy link
Contributor

+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

@rderoldan1
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants