Class: Module
Instance Method Summary collapse
-
#syck_yaml_as(tag, sc = true) ⇒ Object
(also: #yaml_as)
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
#syck_yaml_as(tag, sc = true) ⇒ Object Also known as: yaml_as
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/syck/tag.rb', line 59 def syck_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 Syck.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 != Syck.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 Syck.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.
86 87 88 |
# File 'lib/syck/tag.rb', line 86 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.
91 92 93 |
# File 'lib/syck/tag.rb', line 91 def yaml_tag_read_class( name ) name end |