Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typecasting re-typecasts at every method call #160

Open
bramski opened this issue Apr 11, 2017 · 0 comments
Open

Typecasting re-typecasts at every method call #160

bramski opened this issue Apr 11, 2017 · 0 comments

Comments

@bramski
Copy link

bramski commented Apr 11, 2017

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant