Class: Celluloid::Supervision::Configuration::Instance

### Home Classes Methods

### In Files

- lib/celluloid/supervision/configuration/instance.rb

### Parent

Object

### Methods

- ::new
- #[]
- #[]=
- #define
- #delete
- #export
- #get
- #injection!
- #injections!
- #key?
- #merge
- #merge!
- #ready?
- #resync_accessors
- #set

### Class/Module Index

Quicksearch

- Celluloid
- Celluloid::ClassMethods
- Celluloid::Supervision
- Celluloid::Supervision::Configuration
- Celluloid::Supervision::Configuration::Error
- Celluloid::Supervision::Configuration::Error::AlreadyDefined
- Celluloid::Supervision::Configuration::Error::Incomplete
- Celluloid::Supervision::Configuration::Error::Invalid
- Celluloid::Supervision::Configuration::Error::InvalidSupervisor
- Celluloid::Supervision::Configuration::Error::InvalidValues
- Celluloid::Supervision::Configuration::Injection
- Celluloid::Supervision::Configuration::Instance
- Celluloid::Supervision::Container
- Celluloid::Supervision::Container::Behavior
- Celluloid::Supervision::Container::Behavior::ClassMethods
- Celluloid::Supervision::Container::Behavior::Error
- Celluloid::Supervision::Container::Behavior::Error::Mutant
- Celluloid::Supervision::Container::Injection
- Celluloid::Supervision::Container::Instance
- Celluloid::Supervision::Container::Tree
- Celluloid::Supervision::Error
- Celluloid::Supervision::Error::NoPublicService
- Celluloid::Supervision::Service
- Celluloid::Supervision::Service::Public
- Celluloid::Supervision::Service::Root
- Celluloid::Supervisor

No matching classes.

# Celluloid::Supervision::Configuration::Instance

### Attributes

configuration[RW]

### Public Class Methods

new(configuration={}) click to toggle source

    # File lib/celluloid/supervision/configuration/instance.rb, line 7
    def initialize(configuration={})
      @state = :initializing # :ready
      resync_accessors
      @configuration = configuration
      define(configuration) if configuration.any?
    end

### Public Instance Methods

[](key) click to toggle source
Alias for: get
[]=(key, value) click to toggle source
Alias for: set
define(instance, fail=false) click to toggle source

    # File lib/celluloid/supervision/configuration/instance.rb, line 25
    def define(instance, fail=false)
      fail Configuration::Error::AlreadyDefined if ready? fail
      invoke_injection(:before_configuration)
      @configuration = Configuration.options(instance)
      ready?
    end

delete(k) click to toggle source

    # File lib/celluloid/supervision/configuration/instance.rb, line 101
    def delete(k)
      @configuration.delete(k)
    end

export() click to toggle source

    # File lib/celluloid/supervision/configuration/instance.rb, line 14
    def export
      @configuration.select { |k, v| !REMOVE_AT_EXPORT.include? k }
    end

get(key) click to toggle source

    # File lib/celluloid/supervision/configuration/instance.rb, line 96
    def get(key)
      @configuration[key]
    end

Also aliased as: []
injection!(key, proc) click to toggle source

    # File lib/celluloid/supervision/configuration/instance.rb, line 32
    def injection!(key, proc)
      @configuration[:injections] ||= {}
      @configuration[:injections][key] = proc
    end

injections!(_procs) click to toggle source

    # File lib/celluloid/supervision/configuration/instance.rb, line 37
    def injections!(_procs)
      @configuration[:injections] = proces
    end

key?(k) click to toggle source

    # File lib/celluloid/supervision/configuration/instance.rb, line 87
    def key?(k)
      @configuration.key?(k)
    end

merge(values) click to toggle source

    # File lib/celluloid/supervision/configuration/instance.rb, line 77
    def merge(values)
      if values.is_a? Configuration
        @configuration.merge(values.configuration)
      elsif values.is_a? Hash
        @configuration.merge(values)
      else
        fail Error::Invalid
      end
    end

merge!(values) click to toggle source

    # File lib/celluloid/supervision/configuration/instance.rb, line 73
    def merge!(values)
      @configuration = @configuration.merge(values)
    end

ready?(fail=false) click to toggle source

    # File lib/celluloid/supervision/configuration/instance.rb, line 18
    def ready?(fail=false)
      unless @state == :ready
        @state = :ready if Configuration.valid? @configuration, fail
      end
      @state == :ready
    end

resync_accessors() click to toggle source

    # File lib/celluloid/supervision/configuration/instance.rb, line 41
    def resync_accessors
      # methods for setting and getting the usual defaults
      Configuration.parameters(:mandatory, :optional, :plugins, :meta).each do |key|
        self.class.instance_eval do
          remove_method :"#{key}!" rescue nil # avoid warnings in tests
          define_method(:"#{key}!") { |value| @configuration[key] = value }
        end
        self.class.instance_eval do
          remove_method :"#{key}=" rescue nil # avoid warnings in tests
          define_method(:"#{key}=") { |value| @configuration[key] = value }
        end
        self.class.instance_eval do
          remove_method :"#{key}?" rescue nil # avoid warnings in tests
          define_method(:"#{key}?") { !@configuration[key].nil? }
        end
        self.class.instance_eval do
          remove_method :"#{key}" rescue nil # avoid warnings in tests
          define_method(:"#{key}") { @configuration[key] }
        end
      end

      Configuration.aliases.each do |_alias, _original|
        ["!", :"=", :"?", :""]. each do |m|
          self.class.instance_eval do
            remove_method :"#{_alias}#{m}" rescue nil # avoid warnings in tests
            alias_method :"#{_alias}#{m}", :"#{_original}#{m}"
          end
        end
      end
      true
    end

set(key, value) click to toggle source

    # File lib/celluloid/supervision/configuration/instance.rb, line 91
    def set(key, value)
      @configuration[key] = value
    end

Also aliased as: []=

[Validate]

Generated with the Darkfish Rdoc Generator 2.