karmi/tire — pull request #860 by FestivalBobcats (2013-09-05 18:10:39+00:00)
Title: Cast persistent model attributes according to defined property type on field (when String, Float, or Integer)

```ruby
class PersistentArticleWithTypes
include Tire::Model::Persistence

property :title, :type => 'string'
property :comment_count, :type => 'integer'
property :average_score, :type => 'float'
end

article = PersistentArticleWithTypes.new :title => 12345, :comment_count => '12', :average_score => 10
assert_equal '12345', article.title
assert_equal 12, article.comment_count
assert_equal 10.0, article.average_score
```

The above example is a model and subsequent unit test showing the desired functionality. While the example is definitely contrived, this change will prevent extra steps in the controller to cast param values to the appropriate type. I'm developing a Rails app with Tire as the primary ORM (using ES for storage), and the issue has came up several times now. Unless I'm totally wrong, I do believe this reflects the default behavior of AR and Mongoid.