Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: George Lemon <[email protected]>
  • Loading branch information
georgelemon committed Apr 4, 2024
1 parent de1a760 commit e2bb4d3
Showing 1 changed file with 39 additions and 2 deletions.
41 changes: 39 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,58 @@

## 😍 Key Features
- [x] Compile-time utility tool
- [x] Generate fast getters/setters
- [x] Helps reduce code size & repetitive tasks
- [x] Generate fast `getters`/`setters`
- [x] Callee Introspection

## Examples

#### Getters
Generate fast getters from object fields. Excluding fields is also possible.
```nim
import pkg/voodoo
type
Price* {.getters.} = object
net, gross: string
Product* {.getters.} = object
Product* {.getters: [id].} = object # exclude one or more fields
id: string
title, short_description: string
prices: Price
expandGetters() # is required to expand generated procs.
```

Output:
```nim
proc getNet*(price: Price): string =
## Get `net` from `Price`
result = price.net
proc getGross*(price: Price): string =
## Get `gross` from `Price`
result = price.gross
proc getTitle*(product: Product): string =
## Get `title` from `Product`
result = product.title
proc getShortDescription*(product: Product): string =
## Get `short_description` from `Product`
result = product.short_description
proc getPrices*(product: Product): seq[Price] =
## Get `prices` from `Product`
result = product.prices
```

#### Setters
todo

#### Callee
todo

### ❤ Contributions & Support
- 🐛 Found a bug? [Create a new Issue](https://github.com/openpeeps/voodoo/issues)
- 👋 Wanna help? [Fork it!](https://github.com/openpeeps/voodoo/fork)
Expand Down

0 comments on commit e2bb4d3

Please sign in to comment.