Skip to content

Commit

Permalink
Simplify documentation on handle_async with a class method
Browse files Browse the repository at this point in the history
  • Loading branch information
albus522 committed Dec 19, 2014
1 parent 43c7d9c commit c1c37bf
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,19 +138,15 @@ 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:
To use `handle_asynchronously` on a class method, you must do so within a `class << self` block.
```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
class MyClass
class << self
def slow_method
# some code
end
handle_asynchronously :slow_method
end
handle_asynchronously :my_class_method
end
```

Expand Down

0 comments on commit c1c37bf

Please sign in to comment.