module Celluloid::Supervision::Container::Behavior

Public Class Methods

[](identifier) click to toggle source
# File lib/celluloid/supervision/container/behavior.rb, line 21
def [](identifier)
  @@behaviors[identifier]
end
[]=(identifier, behavior) click to toggle source
# File lib/celluloid/supervision/container/behavior.rb, line 25
def []=(identifier, behavior)
  @@behaviors[identifier] = behavior
end
configure(options) click to toggle source

Beware of order. There may be multiple behavior injections, but their order is not determined ( yet ) Right now, something like a pool-coordinator-tree supervisor mutant are absolutely expected to crash. Therefore, sorry Professor X – we kill every Mutant. On sight, no questions asked. Zero mutant love.

# File lib/celluloid/supervision/container/behavior.rb, line 45
def configure(options)
  behavior = nil
  injection = nil
  @@behaviors.map do |identifier, injector|
    if identifier = parameter(identifier, options)
      if behavior
        raise Error::Mutant, "More than one type of behavior expected."
      else
        if @@injections[injector].include?(:configuration)
          injection = @@injections[behavior = injector][:configuration]
          options[:behavior] ||= behavior
        end
      end
    end
  end

  options[:type] ||= behavior
  injection || proc { @configuration }
end
included(klass) click to toggle source
# File lib/celluloid/supervision/container/behavior.rb, line 13
def included(klass)
  klass.send :extend, ClassMethods
end
injections() click to toggle source
# File lib/celluloid/supervision/container/behavior.rb, line 17
def injections
  @@injections
end
parameter(identifier, options) click to toggle source
# File lib/celluloid/supervision/container/behavior.rb, line 29
def parameter(identifier, options)
  found = nil
  p = Configuration.aliases.each_with_object([identifier]) { |(a, i), invoke| invoke << a if i == identifier; }
  case p.count { |parameter| found = parameter; options.key?(parameter) }
  when 1
    found
  when 0

  else
    raise Error::Mutant, "More than one kind of identifiable behavior parameter."
  end
end