-
Notifications
You must be signed in to change notification settings - Fork 0
/
params.json
1 lines (1 loc) · 1.73 KB
/
params.json
1
{"name":"Sidekiq-ActiveRecord","tagline":"Sidekiq-ORM Project","body":"## Full Example\r\n\r\n```ruby\r\nclass UserMailerTaskWorker < Sidekiq::ActiveRecord::TaskWorker\r\n\r\n sidekiq_task_model :user # or User class\r\n sidekiq_task_options :identifier_key => :token\r\n\r\n def perform_on_model(options)\r\n UserMailer.deliver_registration_confirmation(task_model, options[:new_email])\r\n end\r\n\r\n # optional\r\n def not_found_model(token)\r\n Log.error \"User not found for token:#{token}\"\r\n end\r\n\r\n # optional\r\n def should_perform_on_model?\r\n task_model.active?\r\n end\r\n\r\n # optional\r\n def did_not_perform_on_model\r\n Log.error \"User #{task_model.token} is invalid\"\r\n end\r\n\r\nend\r\n```\r\nWhich can be ran by doing:\r\n```ruby\r\nUserTaskWorker.perform_async(user.id, {:new_email => true})\r\n```\r\n\r\n## Full Example With Aliasing\r\nThe specified ```sidekiq_task_model``` will create method aliases for ```task_model``` and all the hook methods, as follows: \r\n```ruby\r\nclass UserMailerTaskWorker < Sidekiq::ActiveRecord::TaskWorker\r\n\r\n sidekiq_task_model :user # or User class\r\n sidekiq_task_options :identifier_key => :token\r\n\r\n def perform_on_user(options)\r\n UserMailer.deliver_registration_confirmation(user, options[:new_email])\r\n end\r\n\r\n # optional\r\n def not_found_user(token)\r\n Log.error \"User not found for token:#{token}\"\r\n end\r\n\r\n # optional\r\n def should_perform_on_user?\r\n user.active?\r\n end\r\n\r\n # optional\r\n def did_not_perform_on_user\r\n Log.error \"User #{user.token} is invalid\"\r\n end\r\n\r\nend\r\n```","google":"UA-51556764-1","note":"Don't delete this file! It's used internally to help with page regeneration."}