Sha256: 74003c299320334d4b1bce608f4a2441a28a3749dc4751b279cdbb30c0f324d2

Contents?: true

Size: 1.45 KB

Versions: 7

Compression:

Stored size: 1.45 KB

Contents

module SerializationFormat
  def serialized_record
    AssociatedRecord.cache_has_many :deeply_associated_records, :embed => true
    AssociatedRecord.cache_belongs_to :item, :embed => false
    Item.cache_has_many :associated_records, :embed => true
    Item.cache_has_one :associated
    time = Time.parse('1970-01-01T00:00:00 UTC')

    record = Item.new(:title => 'foo')
    record.associated_records << AssociatedRecord.new(:name => 'bar')
    record.associated_records << AssociatedRecord.new(:name => 'baz')
    record.associated = AssociatedRecord.new(:name => 'bork')
    record.not_cached_records << NotCachedRecord.new(:name => 'NoCache', created_at: time)
    record.associated.deeply_associated_records << DeeplyAssociatedRecord.new(:name => "corge", created_at: time)
    record.associated.deeply_associated_records << DeeplyAssociatedRecord.new(:name => "qux", created_at: time)
    record.created_at = time
    record.save
    [Item, NotCachedRecord, DeeplyAssociatedRecord].each do |model|
      model.update_all(updated_at: time)
    end
    record.reload
    Item.fetch(record.id)
    IdentityCache.fetch(record.primary_cache_index_key)
  end

  def serialized_record_file
    File.expand_path("../../fixtures/serialized_record", __FILE__)
  end

  def serialize(record, anIO = nil)
    hash = {
      :version => IdentityCache::CACHE_VERSION,
      :record => record
    }

    if anIO
      Marshal.dump(hash, anIO)
    else
      Marshal.dump(hash)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
identity_cache-0.2.5 test/helpers/serialization_format.rb
identity_cache-0.2.4 test/helpers/serialization_format.rb
identity_cache-0.2.3 test/helpers/serialization_format.rb
identity_cache-0.2.2 test/helpers/serialization_format.rb
identity_cache-0.2.1 test/helpers/serialization_format.rb
identity_cache-0.2.0 test/helpers/serialization_format.rb
identity_cache-0.1.0 test/helpers/serialization_format.rb