123456789_123456789_123456789_123456789_123456789_

Class: Psych::ClassLoader

Relationships & Source Files
Namespace Children
Classes:
Extension / Inclusion / Inheritance Descendants
Subclasses:
Inherits: Object
Defined in: ext/psych/psych_to_ruby.c,
ext/psych/lib/psych/class_loader.rb

Constant Summary

Class Method Summary

Instance Method Summary

Constructor Details

.newClassLoader

This method is for internal use only.
[ GitHub ]

  
# File 'ext/psych/lib/psych/class_loader.rb', line 21

def initialize
  @cache = CACHE.dup
end

Instance Method Details

#find(klassname) (private)

This method is for internal use only.
[ GitHub ]

  
# File 'ext/psych/lib/psych/class_loader.rb', line 47

def find klassname
  @cache[klassname] ||= resolve(klassname)
end

#load(klassname)

This method is for internal use only.
[ GitHub ]

  
# File 'ext/psych/lib/psych/class_loader.rb', line 25

def load klassname
  return nil if !klassname || klassname.empty?

  find klassname
end

#path2class(path) (private)

Convert path string to a class

[ GitHub ]

  
# File 'ext/psych/psych_to_ruby.c', line 22

static VALUE path2class(VALUE self, VALUE path)
{
    return rb_path_to_class(path);
}

#resolve(klassname) (private)

This method is for internal use only.
[ GitHub ]

  
# File 'ext/psych/lib/psych/class_loader.rb', line 51

def resolve klassname
  name    = klassname
  retried = false

  begin
    path2class(name)
  rescue ArgumentError, NameError => ex
    unless retried
      name    = "Struct::#{name}"
      retried = ex
      retry
    end
    raise retried
  end
end

#symbolize(sym)

This method is for internal use only.
[ GitHub ]

  
# File 'ext/psych/lib/psych/class_loader.rb', line 31

def symbolize sym
  symbol
  sym.to_sym
end