diff options
author | why <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-05-13 06:34:18 +0000 |
---|---|---|
committer | why <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-05-13 06:34:18 +0000 |
commit | 447941db717dc53ad89bf639ea82707725090ef4 (patch) | |
tree | 5c96a98d2d411fd2f8324791db1977423fc1e14c /lib/yaml | |
parent | 80fb44602aadc09511d69dceaa4d76481d09a0af (diff) | |
download | ruby-447941db717dc53ad89bf639ea82707725090ef4.tar.gz ruby-447941db717dc53ad89bf639ea82707725090ef4.tar.xz ruby-447941db717dc53ad89bf639ea82707725090ef4.zip |
* lib/yaml/rubytypes.rb: object and struct loading
* lib/yaml.rb: YAML::detect_implicit will discover typing for a Ruby string
* ext/syck/: Fixed portable comments, misuse of NULL and methods without return VALUEs.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@3784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/yaml')
-rw-r--r-- | lib/yaml/rubytypes.rb | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/lib/yaml/rubytypes.rb b/lib/yaml/rubytypes.rb index 727c31ca7..3d4992a29 100644 --- a/lib/yaml/rubytypes.rb +++ b/lib/yaml/rubytypes.rb @@ -160,25 +160,18 @@ class Struct end YAML.add_ruby_type( 'struct' ) { |type, val| - type =~ /^struct:(\w+)/ if Hash === val - type = $1 - struct_type = nil - struct_def = [] - struct_name = "" - if $1.to_s.length > 1 - struct_name = $1[0..$1.length] - struct_def << struct_name - end + struct_type = nil # # Use existing Struct if it exists # begin - struct_type = Struct.const_get( struct_name ) + struct_name, struct_type = YAML.read_type_class( type, Struct ) rescue NameError end if not struct_type + struct_def = [ type.split( ':', 4 ).last ] struct_type = Struct.new( *struct_def.concat( val.keys.collect { |k| k.intern } ) ) end |