Skip to content

Commit e3121e0

Browse files
serraduraclaude
andcommitted
README: show nested block-form in Quick start
Adds an Order/customer example demonstrating inline block-form nesting right after the Micro::Attributes.new one-liner, with anchored links to the block-form and deep-nesting subsections under Composition. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 37cd0ee commit e3121e0

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,22 @@ Person = Micro::Attributes.new do
5555
end
5656
```
5757

58+
Need nested attributes? Define them inline with a [block](#defining-nested-attributes-inline-block-form) — child blocks inherit the host's feature mix and [compose to any depth](#deep-nesting--validation-bubbling):
59+
60+
```ruby
61+
Order = Micro::Attributes.new do
62+
attribute :id, accept: Integer
63+
64+
attribute :customer do
65+
attribute :name, accept: String
66+
attribute :email, accept: String
67+
end
68+
end
69+
70+
order = Order.new(id: 1, customer: { name: 'Rodrigo', email: 'rodrigo@example.com' })
71+
order.customer.name # "Rodrigo"
72+
```
73+
5874
See [Feature overview](#feature-overview) for what else the gem can do.
5975

6076
## Documentation <!-- omit in toc -->

0 commit comments

Comments
 (0)