active_attr
active_attr copied to clipboard
Typecasting re-typecasts at every method call
class MyItemObject
include ActiveAttr::Model
attribute :one
attribute :two
end
Class MyObject
include ActiveAttr::Model
attribute :my_objects, type: [MyArrayObject], typecaster: -> { |values| values.map { |value| MyItemObject.new(value) }
end
object = MyObject.from_json(json_dump)
puts object.my_objects.object_id
puts object.my_objects.object_id
This will produce a different object_id at each run. Can't say I expected this. If typecasting results are temporary perhaps they should be returned as frozen?