### Home Classes Methods

### In Files

- lib/facets/multiton.rb

### Methods

- #_load
- #initialized?
- #instance
- #multiton_id
- #multiton_instance
- #multiton_mutex
- #new
- #reinitialize
- #singleton_method_added

### Included Modules

- Multiton::Inclusive

### Files

- README.rdoc

### Class/Module Index

Quicksearch

- Random
- Random::ArrayExtensions
- Random::HashExtensions
- Random::IntegerExtensions
- Random::NumericExtensions
- Random::RangeExtensions
- Random::StringExtensions
- Random::StringExtensions::Self
- FileUtils
- FileUtils::DryRun
- FileUtils::NoWrite
- FileUtils::Verbose
- Digest
- Digest::Class
- Digest::Instance
- Multiton
- Multiton::Inclusive
- Multiton::MetaMethods
- URI
- URI::Hash
- URI::Kernel
- Argvector
- Argvector
- ERB
- ERB::OpenTemplate
- Enumerable
- Enumerable::Arguments
- GetoptLong
- GetoptLong::DSL
- Memoizable
- Memoizable::Copy
- Numeric
- Numeric::Multipliers
- Object
- Object::ArgVector
- Timer
- Timer::Dummy
- Array
- BasicObject
- CGI
- Cloneable
- Continuation
- Date
- DateTime
- Equitable
- File
- Find
- Hash
- Instantiable
- Integer
- Interval
- Kernel
- Math
- Module
- Net
- NilClass
- NullClass
- OpEsc
- OpenStruct
- Pathname
- Platform
- Range
- RbConfig
- Set
- Shellwords
- String
- StringScanner
- Time
- Tuple
- YAML
- Zlib

No matching classes.

# Multiton::MetaMethods

### Public Instance Methods

initialized?(*e, &b) click to toggle source

    # File lib/facets/multiton.rb, line 230
    def initialized?(*e, &b)
      multiton_instance.key?(multiton_id(*e, &b))
    end

instance(*e, &b) click to toggle source

    # File lib/facets/multiton.rb, line 215
    def instance(*e, &b)
      arg = multiton_id(*e, &b)
      multiton_instance.fetch(arg) do
        multiton_mutex[arg].synchronize do
          multiton_instance.fetch(arg) do
            val = multiton_instance[arg] = new!(*e, &b) #new(*e, &b)
            val.instance_variable_set(:@multiton_initializer, e, &b)
            multiton_mutex.initialized(arg)
            val
          end
        end
      end
    end

Also aliased as: new
new(*e, &b) click to toggle source
Alias for: instance

### Protected Instance Methods

_load(str) click to toggle source

    # File lib/facets/multiton.rb, line 249
    def _load(str)
      instance(*Marshal.load(str))
    end

multiton_instance() click to toggle source

    # File lib/facets/multiton.rb, line 236
    def multiton_instance
      @multiton_instance ||= Hash.new
    end

multiton_mutex() click to toggle source

    # File lib/facets/multiton.rb, line 240
    def multiton_mutex
      @multiton_mutex ||= InstanceMutex.new
    end

reinitialize() click to toggle source

    # File lib/facets/multiton.rb, line 244
    def reinitialize
      multiton_instance.clear
      multiton_mutex.clear
    end

### Private Instance Methods

multiton_id(*e, &b) click to toggle source

Default method to to create a key to cache already constructed instances. In the use case MultitonClass.new(e), MultiClass.new(f) must be semantically equal if multiton_id(e).eql?(multiton_id(f)) evaluates to true.

    # File lib/facets/multiton.rb, line 259
    def multiton_id(*e, &b)
      e
    end

singleton_method_added(sym) click to toggle source

    # File lib/facets/multiton.rb, line 263
    def singleton_method_added(sym)
      super
      if (sym == :marshal_dump) & singleton_methods.include?('marshal_dump')
        raise TypeError, "Don't use marshal_dump - rely on _dump and _load instead"
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.