Sha256: 705397d250f2abfa77ecaadcba9a41849d0c7ed36af47df393301445c953fec4

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

class Module
  yaml_as 'tag:ruby.yaml.org,2002:module'

  def self.yaml_new(_klass, _tag, val)
    val.constantize
  end

  def to_yaml(options = {})
    YAML.quick_emit(nil, options) do |out|
      out.scalar(taguri, name, :plain)
    end
  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

module YAML
  def load_dj(yaml)
    # See https://github.com/dtao/safe_yaml
    # When the method is there, we need to load our YAML like this...
    respond_to?(:unsafe_load) ? load(yaml, :safe => false) : load(yaml)
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
delayed_job_tgmerritt-4.0.7 lib/delayed/syck_ext.rb
delayed_job-4.0.6 lib/delayed/syck_ext.rb
delayed_job-4.0.5 lib/delayed/syck_ext.rb
delayed_job-4.0.4 lib/delayed/syck_ext.rb