ruby - share code between a rails helper and a background worker -


i have code in rails helper being used in view , have same code in background worker class.

how extract code out own class or module use both helper , background class?

please can 1 help.

to me, code needs shared between background tasks , rails goes logically in lib/my_library.rb. require 'my_library' in controller , job files.

lib/my_library.rb:

class mylibrary     def self.do_something(foo)     end end 

in app/jobs/my_job.rb:

require 'my_library'  # ... mylibrary.do_something( "x" ) 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -