Sha256: 37bad8dd1ce08421c1055a3070840dc5c08ebae4df8040f08b938b583bb47d22
Contents?: true
Size: 879 Bytes
Versions: 2
Compression:
Stored size: 879 Bytes
Contents
require 'scorpion/nest' module Scorpion module Rails # Adds a scorpion nest to support injection into rails background worker jobs. module Job def self.included( base ) # Setup dependency injection base.send :include, Scorpion::Object base.send :include, Scorpion::Rails::Nest base.send :around_perform do |job, block| job.with_scorpion &block end super end private def prepare_scorpion( scorpion ) scorpion.prepare do |hunter| hunter.hunt_for ActiveJob::Base do self end end end attr_reader :scorpion def assign_scorpion( scorpion ) @scorpion = scorpion end def free_scorpion @scorpion.try( :destroy ) @scorpion = nil end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
scorpion-ioc-0.5.1 | lib/scorpion/rails/job.rb |
scorpion-ioc-0.5.0 | lib/scorpion/rails/job.rb |