-
Notifications
You must be signed in to change notification settings - Fork 2
/
README
63 lines (41 loc) · 1.22 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
= Bigamy
Enable seamless Ruby-ness between ActiveRecord objects & MongoMapper documents
class User < ActiveRecord::Base
has_one_mm :doc
has_many_mm :photos
end
class Doc
include MongoMapper::Document
belongs_to_ar :user
end
class Photo
include MongoMapper::Document
belongs_to_ar :user
end
Bigamy sets foreign keys upon assignment. It doesn't keep track of dirty children.
It doesn't allow you to operate with new records. So when you do:
@user.doc = @doc
- @user has to be saved already.
- @doc has to be saved already.
- @doc will have it's user_id attribute updated immediately.
When you do:
@user.photos = Photo.all
- every Photo document will have it's user_id attribute set immediately
== Options
The available class methods are:
For AR:
belongs_to_mm
has_one_mm
has_many_mm
For MM:
belongs_to_ar
has_one_ar
has_many_ar
All class methods take :foreign_key, :class, and :primary_key options as a hash
== Setup
Bigamy installs itself into MongoMapper and ActiveRecord automatically.
= License
Bigmay is released under the MIT license.
It's developed by Ryan Angilly and released with the permission of MyPunchbowl.com
= Support
Just email me at [email protected] with questions, bugs, or patches.