mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 06:16:50 +00:00
Move polymorphic to initialize + reader
This commit is contained in:
parent
36feb5d44f
commit
0b6326eb35
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user