An open API service indexing awesome lists of open source software.

https://github.com/grodowski/fnop

Weird attempt to use function composition for service objects
https://github.com/grodowski/fnop

Last synced: 10 months ago
JSON representation

Weird attempt to use function composition for service objects

Awesome Lists containing this project

README

          

Experiment with function composition

Create an operation with

```
operation = fnop do |context|
# do stuff
end

erroring_operation = fnop do |context|
context.stop('nope!')
end
```

Compose them with `>>` and run
```
composed =
operation >> erroring_operation >> operation

data = OpenStruct.new
res = composed.call(data)

res.error
=> 'nope!'
```

See `demo.rb` and `demo_spec.rb` for more examples.