yaml_record icon indicating copy to clipboard operation
yaml_record copied to clipboard

Add array type for property

Open nesquena opened this issue 13 years ago • 1 comments

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]

nesquena avatar Feb 01 '12 08:02 nesquena

Seems to be working here: https://github.com/Nico-Taing/yaml_record/commits/virtus_redux

nesquena avatar Feb 09 '12 01:02 nesquena