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#[] #7

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

Type conversions are not applied for Modelish::Base#[] #7

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 you access the property through the auto-generated accessor, it will perform the type conversion, but if you access the property through the square-bracket hash syntax, it returns the raw, unconverted value:

model.my_prop
# => 42
model[:my_prop]
# => "42"

The Modelish::Base#[] method is currently borrowed from hashie. We need to re-implement it to support modelish-specific concepts like property types (this will probably entail refactoring the property type code as well).

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