jcasimir/draper — Issue #74: do not double decorate
Author: aka47
Created: 2011-11-02 16:19:27+00:00
State: open

a decorator should only decorate a model/collection which exist and also should not double decorate

in base.rb only one line is needed
22 def initialize(input, context = {})
23 return input if input.is_a?(self.class) || input.blank?

instead of double decoration it returns the already decorate model and if input is blank it returns nil.
(a better way to check for blank on collection is to use exists? ..(input.respond_to?(:exists?) ? !input.exists? : input.blank? )

but i have a problem to test it, because there is no real ActiveRecord, maybe time to add AR as dependency, at least for development?