Created
October 12, 2009 01:55
-
-
Save slaskis/208056 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
class User | |
include DataMapper::Resource | |
has 1, :event | |
default_scope.update( :order => [ :priority.desc ] ) | |
property :username, String, :key => true, :unique => true | |
property :name, String, :length => 255 | |
property :email, String, :length => 255 | |
property :phone, String, :length => 255 | |
property :work, String, :length => 255 | |
property :work_url, String, :length => 255 | |
property :avatar_url, String, :length => 255 | |
property :twitter, String, :length => 255 | |
property :blurb, Text | |
property :lat, Float | |
property :lng, Float | |
property :priority, Integer, :default => 0 | |
property :moving, Boolean, :default => false | |
after :save do | |
if @eid | |
event ||= Event.create( :eid => @eid , :user_username => username ) | |
@eid = nil | |
save | |
end | |
end | |
def eid=(id) | |
@eid = id | |
end | |
end | |
class Event | |
include DataMapper::Resource | |
belongs_to :user | |
has n, :streams | |
default_scope.update( :order => [ :start_time.desc ] ) | |
property :id, Serial | |
property :eid, String | |
property :name, String, :length => 255 | |
property :tagline, String, :length => 255 | |
property :start_time, Integer | |
property :end_time, Integer | |
property :location, String, :length => 255 | |
property :description, Text | |
end | |
class Stream | |
include DataMapper::Resource | |
belongs_to :event | |
default_scope.update( :order => [ :uploaded_at.desc ] ) | |
property :id, Serial | |
property :stream_id, String | |
property :state, Enum[ :live , :archived ] | |
property :title, String, :length => 255 | |
property :preview, String, :length => 255 | |
property :uploaded_at, DateTime | |
property :updated_at, DateTime | |
property :created_at, DateTime | |
def created=(at) | |
self[:uploaded_at] = Time.at(at.to_i) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment