-
-
Save arbales/264337 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 :serial, Serial | |
property :days, Flag[:monday, :tuesday, :wednesday, :thursday, :friday, :saturday, :sunday] | |
end | |
DataMapper.auto_migrate! | |
Seating.create(:days => [:monday, :tuesday]) # A | |
Seating.create(:days => [:tuesday]) # B | |
Seating.create(:days => [:monday, :tuesday, :wednesday, :thursday, :friday]) # C | |
p Seating.all(:days => [:tuesday]) # Returns only B | |
p Seating.all(:days => [:monday, :tuesday]) # Returns only B | |
# Sad emoticon :'( |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment