Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- require 'sequel'
- require 'sqlite3'
- require 'sequel/plugins/serialization'
- DB = Sequel.sqlite
- DB.create_table! :players do
- String :name, primary_key: true
- Blob :inventory
- end
- class Player < Sequel::Model
- plugin :serialization
- serialize_attributes :marshal, :inventory
- plugin :serialization_modification_detection
- end
- Player.insert(name: 'joe')
- j = Player['joe']
- j.inventory = {:weapon=>"Sword"}
- j.save
- puts Player.first(name: 'joe').inventory # => {:weapon=>"Sword"}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement