Skip to content

Typecasting re-typecasts at every method call #160

@bramski

Description

@bramski
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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions