Sha256: 2abe357c13024a30333517950f5f4b54cd5140ddc19ec8e68ff640468204b911
Contents?: true
Size: 1.09 KB
Versions: 8
Compression:
Stored size: 1.09 KB
Contents
module Softwear module Lib module Enqueue extend ActiveSupport::Concern module ClassMethods def enqueue(*method_names) if method_names.last.is_a?(Hash) options = method_names.pop else options = {} end method_names.each do |method_name| class_eval <<-RUBY, __FILE__, __LINE__ + 1 def self.#{method_name}(id, *args) find(id).#{method_name}(*args) end RUBY if Rails.env.production? class_eval <<-RUBY, __FILE__, __LINE__ + 1 def enqueue_#{method_name}(*args) self.class.delay(#{options.inspect}).#{method_name}(id, *args) end RUBY else class_eval <<-RUBY, __FILE__, __LINE__ + 1 def enqueue_#{method_name}(*args) self.#{method_name}(*args) end RUBY end end end end included do extend ClassMethods end end end end
Version data entries
8 entries across 8 versions & 1 rubygems