module Bumbleworks

Constants

VERSION

Public Class Methods

autoload_participants() click to toggle source

@public Autoloads all files in the configured participants_directory.

# File lib/bumbleworks.rb, line 125
def autoload_participants
  Bumbleworks::ParticipantRegistration.autoload_all
end
autoload_tasks() click to toggle source

@public Autoloads all files in the configured tasks_directory.

# File lib/bumbleworks.rb, line 132
def autoload_tasks
  Bumbleworks::Task.autoload_all
end
bootstrap!(options = {}) click to toggle source

@public Loads process definitions, and loads participant registration file at configured participant_registration_file path.

# File lib/bumbleworks.rb, line 172
def bootstrap!(options = {})
  load_definitions!(options)
  Bumbleworks::ParticipantRegistration.register!
end
clear_configuration!() click to toggle source

@public Clears configuration completely, resetting to defaults.

# File lib/bumbleworks.rb, line 156
def clear_configuration!
  @configuration = nil
end
configuration() click to toggle source

@public Returns the global configuration, or initializes a new configuration object if it doesn't exist yet. If initializing new config, also adds default storage adapters.

# File lib/bumbleworks.rb, line 50
def configuration
  @configuration ||= begin
    configuration = Bumbleworks::Configuration.new
    configuration.add_storage_adapter(Bumbleworks::HashStorage)
    if defined?(Bumbleworks::Redis::Adapter) && Bumbleworks::Redis::Adapter.auto_register?
      configuration.add_storage_adapter(Bumbleworks::Redis::Adapter)
    end
    if defined?(Bumbleworks::Sequel::Adapter) && Bumbleworks::Sequel::Adapter.auto_register?
      configuration.add_storage_adapter(Bumbleworks::Sequel::Adapter)
    end
    configuration
  end
end
configure() { |configuration| ... } click to toggle source

@public Yields the global configuration to a block. @yield [configuration] global configuration

@example

Bumbleworks.configure do |c|
  c.root = 'path/to/ruote/assets'
end

@see Bumbleworks::Configuration

# File lib/bumbleworks.rb, line 80
def configure(&block)
  unless block
    raise ArgumentError.new("You tried to .configure without a block!")
  end
  yield configuration
end
configure!(&block) click to toggle source

@public Same as .configure, but clears all existing configuration settings first. @yield [configuration] global configuration @see Bumbleworks.configure

# File lib/bumbleworks.rb, line 92
def configure!(&block)
  clear_configuration!
  configure(&block)
end
errors() click to toggle source

@public Instantiates a new Bumbleworks::Process::ErrorRecord for each error in the Ruote storage.

# File lib/bumbleworks.rb, line 194
def errors
  Bumbleworks.dashboard.context.storage.get_many('errors').map { |err|
    Bumbleworks::Process::ErrorRecord.new(
      ::Ruote::ProcessError.new(err)
    )
  }
end
initialize!() click to toggle source

@public Autoloads all necessary files for the Bumbleworks environment

# File lib/bumbleworks.rb, line 163
def initialize!
  autoload_tasks
  autoload_participants
end
launch!(process_definition_name, *args) click to toggle source

@public Launches the process definition with the given process name, as long as that definition name is already registered with Bumbleworks. If options has an :entity key, attempts to extract the id and class name before sending it, so it can be properly stored in workitem fields (and re-instantiated later).

# File lib/bumbleworks.rb, line 184
def launch!(process_definition_name, *args)
  extract_entity_from_fields!(args.first || {})
  pid = Bumbleworks::Ruote.launch(process_definition_name, *args)
  Bumbleworks::Process.new(pid)
end
load_definitions!(options = {}) click to toggle source

@public Registers all process_definitions in the configured definitions_directory with the Ruote engine.

# File lib/bumbleworks.rb, line 140
def load_definitions!(options = {})
  if directory = definitions_directory
    Bumbleworks::ProcessDefinition.create_all_from_directory!(directory, options)
  end
end
register_default_participants() click to toggle source

@public Syntactic sugar to register participants without supplying a block - ends up registering only default participants (such as the error handler and storage).

# File lib/bumbleworks.rb, line 118
def register_default_participants
  register_participants
end
register_participants(&block) click to toggle source

@public Accepts a block for registering participants. Note that a 'catchall Ruote::StorageParticipant' is always added to the end of the list (unless it is defined in the block).

@example

Bumbleworks.register_participants do
  painter PainterClass
  builder BuilderClass
  plumber PlumberClass
end
# File lib/bumbleworks.rb, line 108
def register_participants(&block)
  autoload_participants
  Bumbleworks::Ruote.register_participants(&block)
end
reset!() click to toggle source

@public Resets Bumbleworks - resets dashboard, purges storage, and clears configuration and setup variables.

# File lib/bumbleworks.rb, line 149
def reset!
  Bumbleworks::Ruote.reset!
  clear_configuration!
end
store_history?() click to toggle source

@public Return true only if store_history (from configuration) is true.

# File lib/bumbleworks.rb, line 67
def store_history?
  configuration.store_history == true
end

Private Class Methods

extract_entity_from_fields!(fields) click to toggle source
# File lib/bumbleworks.rb, line 204
def extract_entity_from_fields!(fields)
  begin
    if entity = fields.delete(:entity)
      fields[:entity_id] = entity.identifier
      fields[:entity_type] = entity.class.name
      raise InvalidEntity, "Entity#identifier must be non-null" unless fields[:entity_id]
    end
  rescue NoMethodError => e
    raise InvalidEntity, "Entity must respond to #identifier and #class.name"
  end
end