class Dynflow::Rails
Class for configuring and preparing the Dynflow
runtime environment.
Attributes
config[R]
world[W]
Public Class Methods
new(world_class = nil, config = Rails::Configuration.new)
click to toggle source
# File lib/dynflow/rails.rb, line 10 def initialize(world_class = nil, config = Rails::Configuration.new) @required = false @config = config @world_class = world_class end
Public Instance Methods
eager_load_actions!()
click to toggle source
# File lib/dynflow/rails.rb, line 87 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
executor!()
click to toggle source
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 59 def executor! @executor = true end
executor?()
click to toggle source
# File lib/dynflow/rails.rb, line 63 def executor? @executor end
initialize!()
click to toggle source
# File lib/dynflow/rails.rb, line 29 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 init_world.tap do |world| @world = world config.run_on_init_hooks(false, world) config.increase_db_pool_size(world) unless config.remote? config.run_on_init_hooks(true, world) # leave this just for long-running executors unless config.rake_task_with_executor? invalidated_worlds = world.perform_validity_checks world.auto_execute world.post_initialization if invalidated_worlds > 0 if @world.delayed_executor && !@world.delayed_executor.started? @world.delayed_executor.start end config.run_post_executor_init_hooks(world) end end end end
initialized?()
click to toggle source
# File lib/dynflow/rails.rb, line 25 def initialized? !@world.nil? end
loaded_paths()
click to toggle source
# File lib/dynflow/rails.rb, line 99 def loaded_paths @loaded_paths ||= Set.new end
reinitialize!()
click to toggle source
# File lib/dynflow/rails.rb, line 67 def reinitialize! @world = nil initialize! end
require!()
click to toggle source
call this method if your engine uses Dynflow
# File lib/dynflow/rails.rb, line 17 def require! @required = true end
required?()
click to toggle source
# File lib/dynflow/rails.rb, line 21 def required? @required end
world()
click to toggle source
# File lib/dynflow/rails.rb, line 72 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
Private Instance Methods
init_world()
click to toggle source
# File lib/dynflow/rails.rb, line 105 def init_world return config.initialize_world(@world_class) if @world_class config.initialize_world end