mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22: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)
|
||||
|
||||
attrs.each do |attr|
|
||||
define_method attr do
|
||||
object.read_attribute_for_serialization(attr)
|
||||
unless method_defined?(attr)
|
||||
define_method attr do
|
||||
object.read_attribute_for_serialization(attr)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
4
test/fixtures/poro.rb
vendored
4
test/fixtures/poro.rb
vendored
@ -11,8 +11,6 @@ class Model
|
||||
end
|
||||
|
||||
class ModelSerializer < ActiveModel::Serializer
|
||||
attributes :attr1, :attr2
|
||||
|
||||
def attr2
|
||||
attr2 = object.read_attribute_for_serialization(:attr2)
|
||||
if scope
|
||||
@ -21,4 +19,6 @@ class ModelSerializer < ActiveModel::Serializer
|
||||
attr2
|
||||
end
|
||||
end
|
||||
|
||||
attributes :attr1, :attr2
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user