Sha256: f6e7238a44d039c0eb5d7ef2ab23ff712fa492639e34dac4148fbc66071adaca

Contents?: true

Size: 939 Bytes

Versions: 4

Compression:

Stored size: 939 Bytes

Contents

$: << "~/Projects/Medea/lib"
require 'medea'

class Message < Medea::JasonObject; end

class User < Medea::JasonObject
  owns_many :messages, Message
  has_many :followees, User
end

u1 = User.new
u1.name = "Fred"
u1.save!

u2 = User.new
u2.name = "George"
u2.save!

u1.followees.add! u2
u1.followees.add! (User.get_by_key "p438639000")
u1.followees.add! u1

m1 = Message.new
m1.from = u2.name
m1.message = "Hello! This is George"
u2.messages.add! m1

m3 = Message.new
m3.from = u1.name
m3.message = "George sent me here, hope it's fun!"
u1.messages.add! m3

m2 = Message.new
m2.from = u2.name
m2.message = "Man, this is a long day!"
u2.messages.add! m2

puts "#{u2.name} has posted #{u2.messages.count} messages"

puts "#{u1.name} is following #{u1.followees.count} users"
puts "#{u1.name}'s timeline has #{u1.followees.messages.count} messages in it"

u1.followees.messages.each do |m|
  puts "#{m.from}:"
  puts "      #{m.message}"
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
medea-0.2.29 lib/testsublist.rb
medea-0.2.28 lib/testsublist.rb
Medea-0.2.27 lib/testsublist.rb
Medea-0.2.26 lib/testsublist.rb