yaml_record
yaml_record copied to clipboard
Add array type for property
Once we have typecasting, we should support array as a type:
class Post < YamlRecord::Base
property :names, Array
property :user_ids, Array[Integer]
end
and that should allow:
p = Post.new
p.names = ["Bob", "Jane"]
p.user_ids = [1,2,3,4,5]
p.save
to
---
names: ["Bob", "Jane"]
user_id: [1,2,3,4,5]
but also support lists in string form:
p = Post.new
p.names = "Bob, Jane"
p.user_ids = "1, 2, 3, 4, 5"
p.save
p.names # => ["Bob", "Jane"]
p.user_ids # => [1,2,3,4,5]
Seems to be working here: https://github.com/Nico-Taing/yaml_record/commits/virtus_redux