Skip to content

Instantly share code, notes, and snippets.

@arbales
Created December 21, 2009 04:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arbales/260782 to your computer and use it in GitHub Desktop.
Save arbales/260782 to your computer and use it in GitHub Desktop.
#!/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