We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Old property declaration is:
class Post < YamlRecord::Base # Declare your properties properties :title, :body, :user_id end
which leaves the properties as whatever types they are inside the YAML. But we should support type casting as well:
class Post < YamlRecord::Base # Declare your properties property :title, String property :body, String property :user_id, Integer property :enabled, Boolean property :created_at, DateTime end
This should typecast for String, Integer, DateTime, and Boolean. This means that it will serialize and deserialize and properly cast types:
String
Integer
DateTime
Boolean
p = Post.new(:title => "Test", :user_id => "6", :enabled => "1", :created_at => "6/18/2012") p.title # => "Test" p.user_id # => 6 p.enabled # => true p.created_at # => <Time ...>
and also properly write types out:
--- title: "Test" user_id : 6 enabled : true created_at: "2011-11-05T08:15:30Z"
The text was updated successfully, but these errors were encountered:
Seems to be working here: https://github.com/Nico-Taing/yaml_record/commits/virtus_redux
Sorry, something went wrong.
nicotaing
No branches or pull requests
Old property declaration is:
which leaves the properties as whatever types they are inside the YAML. But we should support type casting as well:
This should typecast for
String
,Integer
,DateTime
, andBoolean
. This means that it will serialize and deserialize and properly cast types:and also properly write types out:
The text was updated successfully, but these errors were encountered: