mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-24 14:56:50 +00:00
Eliminate some String garbage
This commit is contained in:
parent
9da0176d2b
commit
a025f1b6f6
@ -115,6 +115,8 @@ module ActiveModel
|
|||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
class Serializer
|
class Serializer
|
||||||
|
INCLUDE_METHODS = {}
|
||||||
|
|
||||||
class IncludeError < StandardError
|
class IncludeError < StandardError
|
||||||
attr_reader :source, :association
|
attr_reader :source, :association
|
||||||
|
|
||||||
@ -351,6 +353,9 @@ module ActiveModel
|
|||||||
|
|
||||||
def define_include_method(name)
|
def define_include_method(name)
|
||||||
method = "include_#{name}?".to_sym
|
method = "include_#{name}?".to_sym
|
||||||
|
|
||||||
|
INCLUDE_METHODS[name] = method
|
||||||
|
|
||||||
unless method_defined?(method)
|
unless method_defined?(method)
|
||||||
define_method method do
|
define_method method do
|
||||||
true
|
true
|
||||||
@ -504,7 +509,7 @@ module ActiveModel
|
|||||||
end
|
end
|
||||||
|
|
||||||
def include?(name)
|
def include?(name)
|
||||||
send "include_#{name}?".to_sym
|
send INCLUDE_METHODS[name]
|
||||||
end
|
end
|
||||||
|
|
||||||
def include!(name, options={})
|
def include!(name, options={})
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user