Skip to content

Instantly share code, notes, and snippets.

@krobertson
Created December 3, 2008 16:01
Show Gist options
  • Save krobertson/31593 to your computer and use it in GitHub Desktop.
Save krobertson/31593 to your computer and use it in GitHub Desktop.
DataMapper 0.9.7 Marshal.dump Test
require 'rubygems'
require 'dm-core'
DataMapper.setup(:default, 'sqlite3::memory:')
class Dummy
include DataMapper::Resource
property :id, Serial
property :name, String
end
Dummy.auto_migrate!
d = Dummy.new
d.name = 'Test'
d.save
# if I marshal here, it will work, but in most apps, you'll be retrieving existing records
d = Dummy.get(1)
Marshal.dump d
Result:
TypeError: no marshal_dump is defined for class Thread
from (irb):22:in `dump'
from (irb):22
Thread is likely from @transactions in the repository:
irb(main):024:0* d.repository
=> #<DataMapper::Repository:0x113def8 @name=:default, @identity_maps={Dummy=>#<DataMapper::IdentityMap:0x113c2c4 @second_level_cache=nil, @cache={[1]=>#<Dummy id=1 name="Test">}>}, @adapter=#<DataMapper::Adapters::Sqlite3Adapter:0x119f428 @field_naming_convention=DataMapper::NamingConventions::Field::Underscored, @sqlite_version="3.5.8", @resource_naming_convention=DataMapper::NamingConventions::Resource::UnderscoredAndPluralized, @name=:default, @uri=#<struct DataObjects::URI scheme="sqlite3", user=nil, password=nil, host=nil, port=nil, path=":memory:", query=nil, fragment=nil>, @transactions={#<Thread:0x35700 run>=>[]}>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment