Skip to content

Add array type for property #5

@nesquena

Description

@nesquena

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]

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions