Support STI in decorated associations #494

Merged
merged 2 commits into from Mar 11, 2013

Projects

None yet

2 participants

@haines
drapergem member

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.

haines added some commits Mar 10, 2013
@haines haines Revert "Merge pull request #480 from urbanautomaton/decorator-namespa…
…ce-option"

This reverts commit f93542ca7c31cfb950f64f4f19aa68d701f0c095, reversing
changes made to f4dd9e0206929a81274256daf6021b8c821f4757.
2444c09
@haines haines Use source.decorate when decorator is not specified
Closes #490
f64859e
@haines
drapergem member

Umm...

LoadError: no such file to load -- securerandom
require at org/jruby/RubyKernel.java:1027
@steveklabnik
drapergem member

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...

@haines
drapergem member

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 merged commit 07e19cc into drapergem:master Mar 11, 2013

1 check failed

Details default The Travis build failed
@steveklabnik
drapergem member

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

@haines 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