Skip to content
This repository has been archived by the owner on Jun 11, 2022. It is now read-only.

Type conversions are not applied for Modelish::Base#to_s #8

Open
maeve opened this issue Feb 22, 2012 · 0 comments
Open

Type conversions are not applied for Modelish::Base#to_s #8

maeve opened this issue Feb 22, 2012 · 0 comments
Labels

Comments

@maeve
Copy link
Contributor

maeve commented Feb 22, 2012

Given the following modelish object:

class MyModel < Modelish::Base
  property :my_prop, :type => Integer
end

model = MyModel.new(:my_prop => "42")

When rendering the model as a string, the raw value is returned:

model.to_s
# => "#<MyModel my_prop=\"42\">" 

Instead, it should render the property value after type conversion, like so:

model.to_s
# => "#<MyModel my_prop=42>"

This is a relatively minor bug. However, it can certainly cause a lot of confusion in scenarios with more complex type conversion logic (for example, converting nested hashes into a graph of modelish objects).

The Modelish::Base#to_s method is currently borrowed from the hashie base class. It should be re-implemented to support modelish-specific concepts like property types.

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

No branches or pull requests

1 participant