Sha256: b76300f85fceb429b6dc139b457a571f7b3721b914500b344b3532f36b0faad9

Contents?: true

Size: 633 Bytes

Versions: 65

Compression:

Stored size: 633 Bytes

Contents

# YAML marshalling of instances can fail in some circumstances,
# e.g. when the instance has a handle to a Proc.  This monkeypatch limits
# the YAML serialization to just AR's internal @attributes hash.
# The paperclip gem litters AR instances with Procs, for instance.
#
# Courtesy of @ryanlecompte https://gist.github.com/007b88ae90372d1a3321
#

if defined?(::ActiveRecord)
  class ActiveRecord::Base
    yaml_as "tag:ruby.yaml.org,2002:ActiveRecord"

    def self.yaml_new(klass, tag, val)
      klass.unscoped.find(val['attributes'][klass.primary_key])
    end

    def to_yaml_properties
      ['@attributes']
    end
  end
end

Version data entries

65 entries across 65 versions & 3 rubygems

Version Path
sidekiq-2.12.1 lib/sidekiq/yaml_patch.rb
sidekiq-2.12.0 lib/sidekiq/yaml_patch.rb
sidekiq-statsd-0.1.1 vendor/ruby/1.9.1/gems/sidekiq-2.11.2/lib/sidekiq/yaml_patch.rb
sidekiq-statsd-0.1.0 vendor/ruby/1.9.1/gems/sidekiq-2.11.2/lib/sidekiq/yaml_patch.rb
sidekiq-2.11.2 lib/sidekiq/yaml_patch.rb
sidekiq-2.11.1 lib/sidekiq/yaml_patch.rb
sidekiq-2.11.0 lib/sidekiq/yaml_patch.rb
sidekiq-2.10.1 lib/sidekiq/yaml_patch.rb
sidekiq-2.10.0 lib/sidekiq/yaml_patch.rb
sidekiq-2.9.0 lib/sidekiq/yaml_patch.rb
sidekiq-2.8.0 lib/sidekiq/yaml_patch.rb
sidekiq-2.7.5 lib/sidekiq/yaml_patch.rb
sidekiq-2.7.4 lib/sidekiq/yaml_patch.rb
sidekiq-2.7.3 lib/sidekiq/yaml_patch.rb
sidekiq-2.7.2 lib/sidekiq/yaml_patch.rb
sidekiq-2.7.1 lib/sidekiq/yaml_patch.rb
sidekiq-2.7.0 lib/sidekiq/yaml_patch.rb
sidekiq-2.6.5 lib/sidekiq/yaml_patch.rb
sidekiq-2.6.4 lib/sidekiq/yaml_patch.rb
sidekiq-2.6.3 lib/sidekiq/yaml_patch.rb