makandra / active_type

Make any Ruby object quack like ActiveRecord
MIT License
1.09k stars 74 forks source link

make inspect method return more useful information #64

Closed rriksma closed 8 years ago

rriksma commented 8 years ago

When I'm debugging I find it convenient to use the inspect method on objects. Currently only the object name is returned for active_type objects. This code is based on ActiveRecord and it returns names and values of attributes.

I've only started using active_type recently so I might have put the code in the wrong place or something like that.

Thanks!

kratob commented 8 years ago

Thanks for the PR!

This would be useful, but I think the PR has a few issues:

rriksma commented 8 years ago

Would the methods be a good fit for virtual_attributes.rb? if not, what would you name the new module?

kratob commented 8 years ago

You could put it into virtual_attributes.rb, but then you need to change the code so it will also work for ActiveType::Record and display "real" attributes as well as virtual attributes.

Otherwise, perhaps just put it directly into object.rb.

rriksma commented 8 years ago

I don't really understand your comment about "real" attributes. Do you mean attributes that wouldn't have been in the database? I have added a spec that shows it works for records as well. Maybe you could add a failing spec?

kratob commented 8 years ago

I meant actually persisted attributes. See https://github.com/makandra/active_type/commit/38e5669b3037c136fa142c7e52da9dca9532db4c. As it was only a minor change, I've fixed it already. Thanks for the PR.

rriksma commented 8 years ago

Ok, thanks!

kratob commented 8 years ago

Released as 0.5.0.