-
Notifications
You must be signed in to change notification settings - Fork 46
/
README
64 lines (45 loc) · 1.11 KB
/
README
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
Simple in-memory database using ActiveModel.
Primarily developed for Bowline applications.
http://github.com/maccman/bowline
Supports:
* Serialisation
* Validations
* Callbacks
* Observers
* Dirty (Changes)
* Ruby Marshalling to disk
* Redis
Examples:
require "supermodel"
class Test < SuperModel::Base
end
t = Test.new
t.name = "foo"
t.save #=> true
Test.all
Test.first
Test.last
Test.find_by_name('foo)
You can use a random ID rather than the object ID:
class Test < SuperModel::Base
include SuperModel::RandomID
end
t = Test.create(:name => "test")
t.id #=> "7ee935377bb4aecc54ad4f9126"
You can marshal objects to disk on startup/shutdown
class Test < SuperModel::Base
include SuperModel::Marshal::Model
end
SuperModel::Marshal.path = "dump.db"
SuperModel::Marshal.load
at_exit {
SuperModel::Marshal.dump
}
You can use Redis, you need the Redis gem installed:
require "redis"
class Test < SuperModel::Base
include SuperModel::Redis::Model
attributes :name
indexes :name
end
Test.find_or_create_by_name("foo")