From 85bf3d2f3d36736f22e2829a64e637bac2e956f9 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 15 May 2013 15:43:37 -0700 Subject: [PATCH] Move duplicated code to the Base class --- lib/active_model/serializer/associations.rb | 24 +++++++-------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/lib/active_model/serializer/associations.rb b/lib/active_model/serializer/associations.rb index 42bc7546..1a04eda3 100644 --- a/lib/active_model/serializer/associations.rb +++ b/lib/active_model/serializer/associations.rb @@ -45,6 +45,14 @@ module ActiveModel !associated_object.nil? end + def embed_key + if key = options[:embed_key] + key + else + :id + end + end + protected def find_serializable(object) @@ -71,14 +79,6 @@ module ActiveModel end end - def embed_key - if key = options[:embed_key] - key - else - :id - end - end - def id_key "#{@name.to_s.singularize}_ids".to_sym end @@ -135,14 +135,6 @@ module ActiveModel end end - def embed_key - if key = options[:embed_key] - key - else - :id - end - end - def id_key "#{@name}_id".to_sym end