Class: Module
Instance Method Summary collapse
-
#yaml_as(tag, sc = true) ⇒ Object
Adds a taguri tag to a class, used when dumping or loading the class in YAML.
-
#yaml_tag_class_name ⇒ Object
Transforms the subclass name into a name suitable for display in a subclassed tag.
-
#yaml_tag_read_class(name) ⇒ Object
Transforms the subclass name found in the tag into a Ruby constant name.
Instance Method Details
#yaml_as(tag, sc = true) ⇒ Object
Adds a taguri tag to a class, used when dumping or loading the class in YAML. See YAML::tag_class for detailed information on typing and taguris.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/yaml/tag.rb', line 59 def yaml_as( tag, sc = true ) verbose, $VERBOSE = $VERBOSE, nil class_eval " attr_writer :taguri\n def taguri\n if respond_to? :to_yaml_type\n YAML::tagurize( to_yaml_type[1..-1] )\n else\n return @taguri if defined?(@taguri) and @taguri\n tag = \#{ tag.dump }\n if self.class.yaml_tag_subclasses? and self.class != YAML::tagged_classes[tag]\n tag = \"\\\#{ tag }:\\\#{ self.class.yaml_tag_class_name }\"\n end\n tag\n end\n end\n def self.yaml_tag_subclasses?; \#{ sc ? 'true' : 'false' }; end\n end;\n YAML::tag_class tag, self\nensure\n $VERBOSE = verbose\nend\n", __FILE__, __LINE__+1 |
#yaml_tag_class_name ⇒ Object
Transforms the subclass name into a name suitable for display in a subclassed tag.
83 84 85 |
# File 'lib/yaml/tag.rb', line 83 def yaml_tag_class_name self.name end |
#yaml_tag_read_class(name) ⇒ Object
Transforms the subclass name found in the tag into a Ruby constant name.
88 89 90 |
# File 'lib/yaml/tag.rb', line 88 def yaml_tag_read_class( name ) name end |