Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expects and promises #159

Open
cabello opened this issue Oct 2, 2018 · 3 comments
Open

Expects and promises #159

cabello opened this issue Oct 2, 2018 · 3 comments

Comments

@cabello
Copy link

cabello commented Oct 2, 2018

Hi 👋

I recently found this gem https://github.com/adomokos/light-service and one thing I liked was the fact that you can specify what's expected from the context and what will be set on the context.

class LooksUpTaxPercentageAction
  extend LightService::Action
  expects :order
  promises :tax_percentage

I've been doing delegate calls to mimic the expects functionality, I have nothing for the promises.

Is that something you would welcome a PR for?

@natebird
Copy link

natebird commented Oct 2, 2018

I think this would be a worthwhile addition. I've just added comments at the top of the class about what's required input and what is expected output. Defining it might clean up some of the boilerplate code I create like this:

    if context.location.blank? || context.calibration.blank?
      Rails.logger.info 'AddCalibrationLocation [ SKIPPED - MISSING INFO ]'
      return false
    end

@dikond
Copy link

dikond commented Oct 3, 2018

Hey, take a look at Hanami::Interactor - it's simpler than collectiveidea's interactor (no Organizaer, callbacks, rollback) but thanks to its API you can clearly see the input and the output :)

@gee-forr
Copy link

gee-forr commented Aug 4, 2019

You could also try this out: https://github.com/michaelherold/interactor-contracts

It takes what light-service does, and quite a bit further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants