From 0b6326eb352e363951a7911359569f38f35c35ec Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 15 May 2013 17:10:04 -0700 Subject: [PATCH] Move polymorphic to initialize + reader --- lib/active_model/serializer/associations.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/active_model/serializer/associations.rb b/lib/active_model/serializer/associations.rb index e2e13c22..d647d816 100644 --- a/lib/active_model/serializer/associations.rb +++ b/lib/active_model/serializer/associations.rb @@ -80,6 +80,11 @@ module ActiveModel end class HasOne < Base #:nodoc: + def initialize(name, options={}, serializer_options={}) + super + @polymorphic = options[:polymorphic] + end + def root if root = options[:root] root @@ -132,14 +137,13 @@ module ActiveModel private + attr_reader :polymorphic + alias polymorphic? polymorphic + def use_id_key? embed_ids? && !polymorphic? end - def polymorphic? - options[:polymorphic] - end - def polymorphic_key object.class.to_s.demodulize.underscore.to_sym end