sunny / actor

Composable Ruby service objects
MIT License
714 stars 29 forks source link

Forbid sending undefined messages to `ServiceActor::Result` instances #129

Closed viralpraxis closed 8 months ago

viralpraxis commented 8 months ago

Resolves https://github.com/sunny/actor/issues/53

viralpraxis commented 8 months ago

I'm temporary drafting the PR due to unexpected warnings in case of WithUnsetOutput actor

viralpraxis commented 8 months ago

I'm temporary drafting the PR due to unexpected warnings in case of WithUnsetOutput actor

The problems was that outputs are "lazy", i.e

class ... < Actor
  input ...

  output :not_set_value, allow_nil: true
end

will lead to result with empty underlying hash, which will trigger the warning. One solution is to explicitly set outputs to nil so that any unset output will still be accessible without any warnings

sunny commented 8 months ago

I see. Yeah, that makes sense to set it to nil!