Skip to content

Commit

Permalink
Merge pull request #638 from sergey-alekseev/master
Browse files Browse the repository at this point in the history
do not subclass Struct class (update in README)
  • Loading branch information
albus522 committed Apr 9, 2014
2 parents 885074f + 4d8def8 commit 0bd3e9a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ Custom Jobs
Jobs are simple ruby objects with a method called perform. Any object which responds to perform can be stuffed into the jobs table. Job objects are serialized to yaml so that they can later be resurrected by the job runner.

```ruby
class NewsletterJob < Struct.new(:text, :emails)
NewsletterJob = Struct.new(:text, :emails) do
def perform
emails.each { |e| NewsletterMailer.deliver_text_to_email(text, e) }
end
Expand All @@ -241,7 +241,7 @@ Delayed::Job.enqueue NewsletterJob.new('lorem ipsum...', Customers.find(:all).co
```
To set a per-job max attempts that overrides the Delayed::Worker.max_attempts you can define a max_attempts method on the job
```ruby
class NewsletterJob < Struct.new(:text, :emails)
NewsletterJob = Struct.new(:text, :emails) do
def perform
emails.each { |e| NewsletterMailer.deliver_text_to_email(text, e) }
end
Expand Down

0 comments on commit 0bd3e9a

Please sign in to comment.