Ruby‎ > ‎

Merging Other Files

Merging Code

If you need to use other Ruby files in your worker, you'll need to merge them.

If you are using Rails, the SimpleWorker gem will merge all your models for you so you may not need to use this code example. But for code running outside of Rails, you'll need to use the merge method.

class MyWorker < SimpleWorker::Base

  merge "../models/user"
  merge "../models/account.rb"


And just as you can merge, you can also unmerge. Unmerge is generally useful in Rails since it merges some things automatically, but you may not want them:

class MyWorker < SimpleWorker::Base

  unmerge "../models/user"

Merging Other Files (config files, etc)

You can also merge non-ruby files with the same command, eg:

merge 'config.yml'

Then you could load this config in your worker by using: 

@config = YAML.load_file('config.yml')