mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-24 23:06:50 +00:00
Remove method redefined warning
This commit is contained in:
parent
9e75625b1f
commit
0c91564101
@ -20,8 +20,10 @@ module ActiveModel
|
|||||||
@_attributes = attrs.map(&:to_s)
|
@_attributes = attrs.map(&:to_s)
|
||||||
|
|
||||||
attrs.each do |attr|
|
attrs.each do |attr|
|
||||||
define_method attr do
|
unless method_defined?(attr)
|
||||||
object.read_attribute_for_serialization(attr)
|
define_method attr do
|
||||||
|
object.read_attribute_for_serialization(attr)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
4
test/fixtures/poro.rb
vendored
4
test/fixtures/poro.rb
vendored
@ -11,8 +11,6 @@ class Model
|
|||||||
end
|
end
|
||||||
|
|
||||||
class ModelSerializer < ActiveModel::Serializer
|
class ModelSerializer < ActiveModel::Serializer
|
||||||
attributes :attr1, :attr2
|
|
||||||
|
|
||||||
def attr2
|
def attr2
|
||||||
attr2 = object.read_attribute_for_serialization(:attr2)
|
attr2 = object.read_attribute_for_serialization(:attr2)
|
||||||
if scope
|
if scope
|
||||||
@ -21,4 +19,6 @@ class ModelSerializer < ActiveModel::Serializer
|
|||||||
attr2
|
attr2
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
attributes :attr1, :attr2
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user