Skip to content
This repository
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 191 lines (131 sloc) 2.874 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
class FooBar < RelaxDB::Document
  references :bf
end

class BarFoo < RelaxDB::Document
  references :fb
end

class Atom < RelaxDB::Document
end

class Initiative < RelaxDB::Document
  property :x
  attr_reader :foo
  def initialize(data)
    data[:_id] = data[:x]
    super data
    @foo = :bar
  end
end

class Primitives < RelaxDB::Document

  property :str
  property :num
  property :true_bool
  property :false_bool
  property :created_at
  property :updated_at
  property :context
  
  view_docs_by :num
  
  view_by :str

end

class PrimitivesChild < Primitives
end

class BespokeReader < RelaxDB::Document
  property :val
  def val; @data["val"] + 5; end
end

class BespokeWriter < RelaxDB::Document
  property :val
  property :tt
  def val=(v); data["val"] = v - 10; end
end

class Invite < RelaxDB::Document

  property :message

  references :sender
  references :recipient
  
end

class Item < RelaxDB::Document

  property :name
  references :user
  
  view_docs_by :user_id

end

class User < RelaxDB::Document

  property :name, :default => "u"
  property :age
  
  view_docs_by :name, :age

end

class Post < RelaxDB::Document

  property :subject
  property :content
  property :created_at
  property :viewed_at
  
  view_docs_by :content
  view_docs_by :subject
  view_docs_by :viewed_at

end

class Rating < RelaxDB::Document

  property :stars, :default => 5
  references :photo
  
  view_docs_by :stars

end

class Photo < RelaxDB::Document

  property :name

end

class Tag < RelaxDB::Document

  property :name

end

class Tagging < RelaxDB::Document

  references :photo
  references :tag
  property :relevance

end

class Failure < RelaxDB::Document
  property :pathological, :validator => lambda { false }
  references :dysfunctional
end

class Letter < RelaxDB::Document
  property :letter
  property :number
  view_docs_by :letter, :number
  view_docs_by :number
end

class Ancestor < RelaxDB::Document

  property :x
  property :y, :default => true,
    :validator => lambda { |y| y },
    :validation_msg => "Uh oh"
    
  references :user
  property :user_name,
    :derived => [:user, lambda { |p, o| o.user.name } ]
    
  view_docs_by :x
end

class Descendant < Ancestor
end

class SubDescendant < Descendant
end

class RichDescendant < Descendant
  property :foo
  
  references :ukulele
  property :ukulele_name,
    :derived => [:ukulele, lambda { |p, o| o.ukulele.name } ]
end

class Contrived < RelaxDB::Document
  
  attr_accessor :context_count
  def initialize params = {}
    @context_count = 0
    super
  end
  
  property :foo,
    :default => 5,
    :derived => [
      :context,
      lambda { |f, c| c.context_count += 1; 10 }
    ]
  
  references :context
end

module Inh
  
  class X < RelaxDB::Document; end

  class Y < X; end
  class Y1 < Y; end
  
  class Z < X; end
  class Z1 < Z; end
  class Z2 < Z; end
  
end
Something went wrong with that request. Please try again.