Sha256: 238562d24a59b8bb53d23c440fffe59b6638338e5062332254af6834b04af786
Contents?: true
Size: 1 KB
Versions: 2
Compression:
Stored size: 1 KB
Contents
# These extensions allow properly serializing and autoloading of # Classes, Modules and Structs require 'yaml' YAML::ENGINE.yamler = "syck" if defined?(YAML::ENGINE) class Module yaml_as "tag:ruby.yaml.org,2002:module" def self.yaml_new(klass, tag, val) val.constantize end def to_yaml( opts = {} ) YAML::quick_emit( nil, opts ) { |out| out.scalar(taguri, self.name, :plain) } end def yaml_tag_read_class(name) # Constantize the object so that ActiveSupport can attempt # its auto loading magic. Will raise LoadError if not successful. name.constantize name end end class Class yaml_as "tag:ruby.yaml.org,2002:class" remove_method :to_yaml if respond_to?(:to_yaml) && method(:to_yaml).owner == Class # use Module's to_yaml end class Struct def self.yaml_tag_read_class(name) # Constantize the object so that ActiveSupport can attempt # its auto loading magic. Will raise LoadError if not successful. name.constantize "Struct::#{ name }" end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
delayed_job_hooked-2.1.5 | lib/delayed/yaml_ext.rb |
delayed_job-2.1.4 | lib/delayed/yaml_ext.rb |