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
-
BIG_DECIMAL =
Internal use only
# File 'ext/psych/lib/psych/class_loader.rb', line 7'BigDecimal'
-
CACHE =
Internal use only
# File 'ext/psych/lib/psych/class_loader.rb', line 65Hash[constants.map { |const| val = const_get const begin [val, ::Object.const_get(val)] rescue nil end }.compact]
-
COMPLEX =
Internal use only
# File 'ext/psych/lib/psych/class_loader.rb', line 8'Complex'
-
DATE =
Internal use only
# File 'ext/psych/lib/psych/class_loader.rb', line 9'Date'
-
DATE_TIME =
Internal use only
# File 'ext/psych/lib/psych/class_loader.rb', line 10'DateTime'
-
EXCEPTION =
Internal use only
# File 'ext/psych/lib/psych/class_loader.rb', line 11'Exception'
-
OBJECT =
Internal use only
# File 'ext/psych/lib/psych/class_loader.rb', line 12'Object'
-
PSYCH_OMAP =
Internal use only
# File 'ext/psych/lib/psych/class_loader.rb', line 13'Psych::Omap'
-
PSYCH_SET =
Internal use only
# File 'ext/psych/lib/psych/class_loader.rb', line 14'Psych::Set'
-
RANGE =
Internal use only
# File 'ext/psych/lib/psych/class_loader.rb', line 15'Range'
-
RATIONAL =
Internal use only
# File 'ext/psych/lib/psych/class_loader.rb', line 16'Rational'
-
REGEXP =
Internal use only
# File 'ext/psych/lib/psych/class_loader.rb', line 17'Regexp'
-
STRUCT =
Internal use only
# File 'ext/psych/lib/psych/class_loader.rb', line 18'Struct'
-
SYMBOL =
Internal use only
# File 'ext/psych/lib/psych/class_loader.rb', line 19'Symbol'
Class Method Summary
- .new ⇒ ClassLoader constructor Internal use only
Instance Method Summary
-
#path2class(path)
private
Convert
path
string to a class. - #load(klassname) Internal use only
- #symbolize(sym) Internal use only
- #find(klassname) private Internal use only
- #resolve(klassname) private Internal use only
Constructor Details
.new ⇒ ClassLoader
This method is for internal use only.
# 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 45
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
# 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 49
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