Support STI in decorated associations #494

Merged
merged 2 commits into from Mar 11, 2013

Conversation

Projects
None yet
2 participants
Contributor

haines commented Mar 10, 2013

This introduces the following precedence for choosing how to decorate an association:

  1. The decorator given by the with option
  2. The source's decorate method
  3. A generic CollectionDecorator (for collection associations only)

I reverted the decorator namespace commit - I really like the feature but am not quite there on the implementation - it made the changes here a bit more difficult than they should have been. I'd like to find a way to do decorator namespacing without having to pass the namespace option around everywhere.

Contributor

haines commented Mar 10, 2013

Umm...

LoadError: no such file to load -- securerandom
require at org/jruby/RubyKernel.java:1027
Owner

steveklabnik commented Mar 10, 2013

I'm getting it elsewhere too: https://travis-ci.org/rails-api/active_model_serializers/jobs/5382513

Travis updated tons of things yesterday, I bet that's it...

Contributor

haines commented Mar 10, 2013

Yeah, seems to be broken with the update to JRuby 1.7.3, I'm away from my dev machine this week (and so am stuck on Windows 😱) so I haven't tried to reproduce locally. I filed an issue anyway, let's see what they say jruby/jruby#572

@steveklabnik steveklabnik added a commit that referenced this pull request Mar 11, 2013

@steveklabnik steveklabnik Merge pull request #494 from haines/sti
Support STI in decorated associations
07e19cc

@steveklabnik steveklabnik merged commit 07e19cc into drapergem:master Mar 11, 2013

1 check failed

default The Travis build failed
Details
Owner

steveklabnik commented Mar 11, 2013

Since it's Travis' fault, I'm merging. Thanks! ❤️

haines deleted the unknown repository branch Mar 11, 2013

@urbanautomaton urbanautomaton added a commit to urbanautomaton/draper that referenced this pull request Mar 13, 2013

@urbanautomaton urbanautomaton Add option to specify namespace for decorator lookup
To use different decorators in different contexts (e.g. HTML rendering
vs. API representation), the ability to specify a decorator namespace is
added. For example:

    > Product.new.decorate
    => #<ProductDecorator:0x0000010b6e47e8>
    > Product.new.decorate(:namespace => HTML)
    => #<HTML::ProductDecorator:0x0000010b6e47e9>

Second attempt, following #480 and #494.
315ee51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment