Skip to content

Instantly share code, notes, and snippets.

@arbales
Created Dec 21, 2009
Embed
What would you like to do?
#!/usr/bin/env ruby -Ku
# encoding: utf-8
require 'rubygems'
require 'dm-core'
require 'dm-types'
DataMapper::Logger.new($stdout, :debug)
DataMapper.setup(:default, "sqlite3:///#{Dir.pwd}/examine.db")
class Seating
include DataMapper::Resource
property :id, Serial
property :days, Flag[:monday, :tuesday, :wednesday, :thursday, :friday, :saturday, :sunday]
end
DataMapper.auto_upgrade!
if (!Seating.first())
s = Seating.new()
s.save()
p s
s.days = [:monday]
s.save() # This works.
p s # :monday
s.days << :tuesday
p s # :monday, :tuesday
else
p Seating.first() # :monday
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment