mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 06:16:50 +00:00
Move duplicated code to the Base class
This commit is contained in:
parent
03669a74bc
commit
85bf3d2f3d
@ -45,6 +45,14 @@ module ActiveModel
|
|||||||
!associated_object.nil?
|
!associated_object.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def embed_key
|
||||||
|
if key = options[:embed_key]
|
||||||
|
key
|
||||||
|
else
|
||||||
|
:id
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def find_serializable(object)
|
def find_serializable(object)
|
||||||
@ -71,14 +79,6 @@ module ActiveModel
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def embed_key
|
|
||||||
if key = options[:embed_key]
|
|
||||||
key
|
|
||||||
else
|
|
||||||
:id
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def id_key
|
def id_key
|
||||||
"#{@name.to_s.singularize}_ids".to_sym
|
"#{@name.to_s.singularize}_ids".to_sym
|
||||||
end
|
end
|
||||||
@ -135,14 +135,6 @@ module ActiveModel
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def embed_key
|
|
||||||
if key = options[:embed_key]
|
|
||||||
key
|
|
||||||
else
|
|
||||||
:id
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def id_key
|
def id_key
|
||||||
"#{@name}_id".to_sym
|
"#{@name}_id".to_sym
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user