Method: Module#syck_yaml_as

Defined in:
lib/syck/tag.rb

#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