Skip to content

Conversation

@claudiob
Copy link

This PR is more to start a feature discussion than to actually merge this code :)

I use performs a lot in my codebase, often with wait: and wait_until:, at times like this:

performs :notify_customer, wait: 1.second

but more commonly like this:

performs :send_offer, wait_until: ->(nomination) { nomination.earliest_operating_time }

In other words, the waiting time is dictated by a method that belongs to the same record.


My feature proposal is to be able to rewrite the last example like this:

performs :send_offer, wait_until: :earliest_operating_time

The (terrible) code in this commit is just to prove that it can be done. @kaspth is this something you would be interested in? I can write better code if that's the case :)

This PR is more to start a feature discussion than to actually merge this code :)

I use `performs` a lot in my codebase, often with `wait:` and `wait_until:`, at times like this:

```ruby
performs :notify_customer, wait: 1.second
```

but more commonly like this:

```ruby
performs :send_offer, wait_until: ->(nomination) { nomination.earliest_operating_time }
```

In other words, the waiting time is dictated by a method that belongs to the same record.

---

My feature proposal is to be able to rewrite the last example like this:

```ruby
performs :send_offer, wait_until: :earliest_operating_time
```

The (terrible) code in this commit is just to prove that it can be done.
@kaspth is this something you would be interested in? I can write better code if that's the case :)
@kaspth
Copy link
Owner

kaspth commented Jan 29, 2026

@claudiob got caught up in a bunch of other work, but yeah, this seems alright to me and helpful if users are passing private methods.

end

def wait_until=(value)
@wait_until_symbol = value if value.is_a?(Symbol)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we could use instance_method here to grab the method early? If so, I don't think we'd need special handling below.

@kaspth
Copy link
Owner

kaspth commented Jan 29, 2026

performs :notify_customer, wait: 1.second

I'm curious, is 1 second picked for the example or are you using it in real life too? What cases do you do that for? 😊

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

Successfully merging this pull request may close these issues.

2 participants