Sha256: dba57aece609886847d8333ea5a8f8438bd400570c18722b61bd63c33afe78f0
Contents?: true
Size: 1.63 KB
Versions: 7
Compression:
Stored size: 1.63 KB
Contents
require "rails" require "eitil_wrapper" module EitilWrapper class Railtie < Rails::Railtie initializer "my_railtie.configure_rails_initialization", options: :after do |app| # Dynamic dispatching after initialization of Rails classes. # Scopes if Object.const_defined?('EitilWrapper::Scopes::DefaultScopes') ::ApplicationRecord.send(:extend, EitilWrapper::Scopes::DefaultScopes) end # Jobs if Object.const_defined?('EitilWrapper::CreateSingleMethodJob') # ISSUE: this code is currently defined eitil_wrapper/railtie.rb, since module inclusion # somehow leads to errors in the initialization process. Ideally, this code would be # defined in eitil_wrapper/jobs/single_method_job.rb and dispatched in eitil_wrapper/railtie.rb # BEWARE: _self is currently not accepted in perform_later jobs due to serialization errors # BEWARE: The cases of 'id' and '_self' both handle instances, with the difference # being that 'id' works for objects that have a database record, while '_self' # works for non database supported instanes, such as an Exporter instance. module ::EitilWrapper class SingleMethodJob < ::ApplicationJob def perform(*args, _class:, _method:, id: nil, _self: nil, **kwargs) object = if id _class.constantize.find(id) elsif _self _self else _class.constantize end object.send _method, *args, **kwargs end; end; end; end end end end
Version data entries
7 entries across 7 versions & 1 rubygems