Giter Club home page Giter Club logo

Comments (4)

padi avatar padi commented on May 28, 2024

Actually, it might be enough to have something like Action.options :milk, so that we have access to ctx.milk w/o adding it to Action.expects:

class AddsMilk
  include LightService::Action
  expects :cup
  options :milk # like expects, but doesn't raise errors if missing

  executed do |ctx|
      next ctx unless ctx.milk
      ctx.cup.add ctx.milk
  end
end

from light-service.

adomokos avatar adomokos commented on May 28, 2024

@padi: Let me try to summerize what I read above.

  1. You have 4 actions the organizer will execute
  2. Since you are expecting milk to be in the context for the 3rd action, the previous action has to add it to the context in order to avoid the ExpectedKeyNotInContextError exception
  3. You suggest making milk an optional attribute in the context so your 2nd (or an earlier) action does not have to set it explicitly nil

If all the statments above are correct, what would the context set the optional attributes? Just nil?

I have not bumped into this scenario just yet, but I could see this being a problem if you want to reuse actions with different organizers using different contexts. We try to make our actions so small, that if something does not fit in it, we just create another action for it. You guys might be pushing this further than what we use it for.

It would be helpful if you could send a PR with a new spec in it, that better demonstrates the problem. A test should tell us the whole story, right?

from light-service.

adomokos avatar adomokos commented on May 28, 2024

@padi: Any update on this? What should I do with this issue?

from light-service.

padi avatar padi commented on May 28, 2024

I don't remember the particular scenario that prompted me to post this PR. I'll close this issue for now until we encounter a really painful scenario that absolutely requires something like this.

from light-service.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.