Class: Module

Inherits:
Object
  • Object
show all
Defined in:
lib/jvyaml.rb

Overview

From yaml/tag.rb

Instance Method Summary collapse

Instance Method Details

#jvyaml_as(tag, sc = true) ⇒ Object

Adds a taguri tag to a class, used when dumping or loading the class in JvYAML. See JvYAML::tag_class for detailed information on typing and taguris.



341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
# File 'lib/jvyaml.rb', line 341

def jvyaml_as( tag, sc = true )
    verbose, $VERBOSE = $VERBOSE, nil
    class_eval <<-"end;", __FILE__, __LINE__+1
        attr_writer :jv_taguri
        def jv_taguri
            if respond_to? :to_jvyaml_type
                JvYAML::tagurize( to_jvyaml_type[1..-1] )
            else
                return @jv_taguri if defined?(@jv_taguri) and @jv_taguri
                tag = #{ tag.dump }
                if self.class.jvyaml_tag_subclasses? and self.class != JvYAML::tagged_classes[tag]
                    tag = "\#{ tag }:\#{ self.class.jvyaml_tag_class_name }"
                end
                tag
            end
        end
        def self.jvyaml_tag_subclasses?; #{ sc ? 'true' : 'false' }; end
    end;
    JvYAML::tag_class tag, self
ensure
    $VERBOSE = verbose
end

#jvyaml_tag_class_nameObject

Transforms the subclass name into a name suitable for display in a subclassed tag.



365
366
367
# File 'lib/jvyaml.rb', line 365

def jvyaml_tag_class_name
    self.name
end

#jvyaml_tag_read_class(name) ⇒ Object

Transforms the subclass name found in the tag into a Ruby constant name.



370
371
372
# File 'lib/jvyaml.rb', line 370

def jvyaml_tag_read_class( name )
    name
end