Skip to content

Commit

Permalink
Show how to add #handle_asynchronously to class methoda
Browse files Browse the repository at this point in the history
  • Loading branch information
rdpoor committed Dec 17, 2014
1 parent 6b766a5 commit 23faf83
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
Expand Up @@ -138,6 +138,22 @@ class LongTasks
end
```

What if you want to apply `handle_asynchronously` to a class method? That's no problem, just use Ruby's syntax to create a singleton class method, so if you had this:
```ruby
def self.my_class_method
# some code
end
```
you can instruct Delayed Job to run it in the background like this:
```ruby
class << self
def my_class_method
# some code
end
handle_asynchronously
end
```

If you ever want to call a `handle_asynchronously`'d method without Delayed Job, for instance while debugging something at the console, just add `_without_delay` to the method name. For instance, if your original method was `foo`, then call `foo_without_delay`.

Rails 3 Mailers
Expand Down

0 comments on commit 23faf83

Please sign in to comment.