Module: Laser::Analysis::SingletonClassFactory

Defined in:
lib/laser/analysis/bootstrap/laser_singleton_class.rb

Class Method Summary (collapse)

Class Method Details

+ (Object) create_for(ruby_obj)



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/laser/analysis/bootstrap/laser_singleton_class.rb', line 4

def self.create_for(ruby_obj)
  if nil == ruby_obj
    return ClassRegistry['NilClass']
  elsif true == ruby_obj
    return ClassRegistry['TrueClass']
  elsif false == ruby_obj
    return ClassRegistry['FalseClass']
  else
    name = "Instance:#{ruby_obj.inspect}"
    existing = ProtocolRegistry[name].first
    existing || LaserSingletonClass.new(
        ClassRegistry['Class'], Scope::GlobalScope, name, ruby_obj) do |new_singleton_class|
      new_singleton_class.superclass = ClassRegistry[ruby_obj.class.name]
    end
  end
end