Class: Ruby::Reflection

Inherits:
Object
  • Object
show all
Includes:
AbstractReflection
Defined in:
lib/ruby/reflection.rb,
lib/ruby/reflection/mirror.rb,
lib/ruby/reflection/class_mirror.rb,
lib/ruby/reflection/field_mirror.rb,
lib/ruby/reflection/thread_mirror.rb,
lib/ruby/reflection/object_mirror.rb,
lib/ruby/reflection/field_mirror/constant_mirror.rb,
lib/ruby/reflection/field_mirror/class_variable_mirror.rb,
lib/ruby/reflection/field_mirror/instance_variable_mirror.rb

Defined Under Namespace

Classes: ClassMirror, ClassVariableMirror, ConstantMirror, FieldMirror, InstanceVariableMirror, Mirror, ObjectMirror, ThreadMirror

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods included from AbstractReflection

included, #reflect_object

Class Method Details

+ (Object) codebase



12
13
14
# File 'lib/ruby/reflection.rb', line 12

def self.codebase
  nil.class
end

+ (Object) reflect(ignored)



16
17
18
# File 'lib/ruby/reflection.rb', line 16

def self.reflect(ignored)
  self.new
end

Instance Method Details

- (Object) classes



24
25
26
# File 'lib/ruby/reflection.rb', line 24

def classes
  instances_of(Class)
end

- (Object) engine



48
49
50
# File 'lib/ruby/reflection.rb', line 48

def engine
  RUBY_ENGINE
end

- (Object) instances_of(klass)



28
29
30
# File 'lib/ruby/reflection.rb', line 28

def instances_of(klass)
  mirrors ObjectSpace.each_object(klass).select {|obj| obj.class == klass }
end

- (Object) modules



20
21
22
# File 'lib/ruby/reflection.rb', line 20

def modules
  instances_of(Module)
end

- (Object) object_by_id(id)



32
33
34
35
36
37
38
# File 'lib/ruby/reflection.rb', line 32

def object_by_id(id)
  if obj = ObjectSpace._id2ref(id)
    Mirror.reflect obj
  else
    nil
  end
end

- (Object) platform



44
45
46
# File 'lib/ruby/reflection.rb', line 44

def platform
  RUBY_PLATFORM
end

- (Object) threads



40
41
42
# File 'lib/ruby/reflection.rb', line 40

def threads
  instances_of(Thread)
end

- (Object) version



52
53
54
# File 'lib/ruby/reflection.rb', line 52

def version
  Object.const_get("#{RUBY_ENGINE.upcase}_VERSION")
end