Last active
January 3, 2016 12:09
-
-
Save benmoss/8460895 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActiveModel | |
class Serializer | |
module Associations | |
class HasOne < Config | |
def root | |
if root = option(:root) | |
root | |
elsif polymorphic? | |
polymorphic_name.pluralize.to_sym | |
else | |
@name.to_s.pluralize.to_sym | |
end | |
end | |
def polymorphic_key | |
polymorphic_name.to_sym | |
end | |
private | |
def polymorphic_name | |
associated_object.active_model_serializer.name.demodulize.gsub("Serializer", "").underscore | |
end | |
end | |
end | |
end | |
end | |
class Admin | |
def active_model_serializer | |
SuperUserSerializer | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment