Sha256: 1d2f21dbd8dc8f8c628272abc374611bdc98745fddc5503e350ec59f55c6ea0a

Contents?: true

Size: 608 Bytes

Versions: 1

Compression:

Stored size: 608 Bytes

Contents

module ObjectSpace
  def self.each_object(target_klass, &block)
    klasses = [Object]
    i = 0
    loop do
      klass = klasses[i]
      yield klass
      names = `klass.$$const` && `Object.keys(klass.$$const)`
      names.each do |name|
        begin
          k = klass.const_get(name) rescue nil
          next unless `k.$$const`
          next unless k.respond_to?(:is_a?)
          next if klasses.include?(k)

          klasses << k if k.is_a? target_klass
        rescue Exception => e
          next
        end
      end if names
      i += 1
      break if i >= klasses.length
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hyper-state-1.0.alpha1.8 lib/ext/object_space.rb