Class for configuring and preparing the Dynflow runtime environment.
# File lib/dynflow/rails.rb, line 9 def initialize(config = Rails::Configuration.new) @required = false @config = config end
# File lib/dynflow/rails.rb, line 78 def eager_load_actions! config.eager_load_paths.each do |load_path| Dir.glob("#{load_path}/**/*.rb").sort.each do |file| unless loaded_paths.include?(file) require_dependency file loaded_paths << file end end end @world.reload! if @world end
Mark that the process is executor. This prevents the remote setting from applying. Needs to be set up before the world is being initialized
# File lib/dynflow/rails.rb, line 50 def executor! @executor = true end
# File lib/dynflow/rails.rb, line 54 def executor? @executor end
# File lib/dynflow/rails.rb, line 27 def initialize! return unless @required return @world if @world if config.lazy_initialization && defined?(::PhusionPassenger) config.dynflow_logger. warn('Dynflow: lazy loading with PhusionPassenger might lead to unexpected results') end config.initialize_world.tap do |world| @world = world unless config.remote? config.run_on_init_hooks(world) # leave this just for long-running executors unless config.rake_task_with_executor? world.auto_execute end end end end
# File lib/dynflow/rails.rb, line 23 def initialized? !@world.nil? end
# File lib/dynflow/rails.rb, line 90 def loaded_paths @loaded_paths ||= Set.new end
# File lib/dynflow/rails.rb, line 58 def reinitialize! @world = nil initialize! end
call this method if your engine uses Dynflow
# File lib/dynflow/rails.rb, line 15 def require! @required = true end
# File lib/dynflow/rails.rb, line 19 def required? @required end
# File lib/dynflow/rails.rb, line 63 def world return @world if @world initialize! if config.lazy_initialization unless @world raise 'The Dynflow world was not initialized yet. ' 'If your plugin uses it, make sure to call Rails.application.dynflow.require! ' 'in some initializer' end @world end