Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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.

None yet

3 participants