Skip to content

Commit 0563a9a

Browse files
authored
fix markdown badge (#12)
* fix markdown badge * simplify Sidekiq job section * simplify conditional docs
1 parent 47d1009 commit 0563a9a

File tree

1 file changed

+13
-43
lines changed

1 file changed

+13
-43
lines changed

README.md

+13-43
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
![Ruby 3.3.0](https://img.shields.io/badge/ruby-3.3.0-green.svg)
77
![Ruby 3.2.2](https://img.shields.io/badge/ruby-3.2.2-green.svg)
88
![Ruby 3.1.4](https://img.shields.io/badge/ruby-3.1.4-green.svg)
9-
![Code Climate](https://codeclimate.com/github/markburns/interactify/badges/gpa.svg)(https://codeclimate.com/github/markburns/interactify)
9+
[![Code Climate](https://codeclimate.com/github/markburns/interactify/badges/gpa.svg)](https://codeclimate.com/github/markburns/interactify)
1010

1111
Interactify enhances Rails applications by simplifying complex interactor chains.
1212
This gem builds on [interactors](https://github.com/collectiveidea/interactor) and [interactor-contracts](https://github.com/michaelherold/interactor-contracts) to improve readability and maintainability of business logic.
@@ -224,26 +224,16 @@ class OuterThing
224224
# ... boilerplate ...
225225
organize \
226226
SetupStep,
227-
self.if(->(c){ c.thing == 'a' }, DoThingA, DoThingB),
228-
end
229227

230-
# or hash syntax
231-
class OuterThing
232-
# ... boilerplate ...
233-
organize \
234-
{if: :key_set_on_context, then: DoThingA, else: DoThingB},
235-
AfterBothCases
236-
end
237-
```
228+
# lambda conditional
229+
self.if(->(c){ c.thing == 'a' }, DoThingA, DoThingB),
238230

239-
### Conditionals with a key from the context
231+
# context conditional
232+
self.if(:some_key_on_context, DoThingA, DoThingB),
240233

241-
```ruby
242-
class OuterThing
243-
# ... boilerplate ...
244-
organize \
245-
self.if(:key_set_on_context, DoThingA, DoThingB),
246-
AfterBothCases
234+
# alternative hash syntax
235+
{if: :key_set_on_context, then: DoThingA, else: DoThingB},
236+
AfterDoThis
247237
end
248238
```
249239

@@ -263,6 +253,7 @@ class SomeOrganizer
263253
end
264254

265255
```
256+
266257
### Contract validation failures
267258
Sometimes contract validation fails at runtime as an exception. It's something unexpected and you'll have an `Interactor::Failure` sent to rollbar/sentry/honeybadger.
268259
If the context is large it's often hard to spot what the actual problem is or where it occurred.
@@ -311,7 +302,6 @@ Actual promises are:
311302
step1
312303
```
313304

314-
315305
### Interactor wiring specs
316306
Sometimes you have an interactor chain that fails because something is expected deeper down the chain and not provided further up the chain.
317307
The existing way to solve this is with enough integration specs to catch them, hunting and sticking a `byebug`, `debugger` or `binding.pry` in at suspected locations and inferring where in the chain the wiring went awry.
@@ -351,17 +341,7 @@ expect(described_class).to promise_outputs(:order)
351341
### Sidekiq Jobs
352342
Sometimes you want to asyncify an interactor.
353343

354-
```ruby
355-
# before
356-
class SomeInteractor
357-
include Interactify
358-
359-
def call
360-
# ...
361-
end
362-
end
363-
```
364-
344+
#### before
365345
```diff
366346
- SomeInteractor.call(*args)
367347
+ class SomeInteractorJob
@@ -375,24 +355,14 @@ end
375355
+ SomeInteractorJob.perform_async(*args)
376356
```
377357

378-
```ruby
379-
# after
380-
class SomeInteractor
381-
include Interactify
382-
383-
def call
384-
# ...
385-
end
386-
end
387-
```
388-
389-
No need to manually create a job class or handle the perform/call impedance mismatch
390-
358+
#### after
391359
```diff
392360
- SomeInteractor.call!(*args)
393361
+ SomeInteractor::Async.call!(*args)
394362
```
395363

364+
No need to manually create a job class or handle the perform/call impedance mismatch
365+
396366
This also makes it easy to add cron jobs to run interactors. As any interactor can be asyncified.
397367
By using it's internal Async class.
398368

0 commit comments

Comments
 (0)