bigamy 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README CHANGED
@@ -1,11 +1,70 @@
1
1
  = Bigamy
2
-
3
2
  Enable seamless Ruby-ness between ActiveRecord objects & MongoMapper documents
4
3
 
5
- = License
4
+ class User < ActiveRecord::Base
5
+ Bigamy.setup self
6
+
7
+ has_one_mm :doc
8
+ has_many_mm :photos
9
+ end
10
+
11
+ class Doc
12
+ include MongoMapper::Document
13
+ Bigamy.setup self
14
+
15
+ belongs_to_ar :user
16
+ end
17
+
18
+ class Photo
19
+ include MongoMapper::Document
20
+ Bigamy.setup self
21
+
22
+ belongs_to_ar :user
23
+ end
24
+
25
+
26
+ Bigamy sets foreign keys upon assignment. It doesn't keep track of dirty children.
27
+ It doesn't allow you to operate with new records. So when you do:
28
+
29
+ @user.doc = @doc
30
+
31
+ - @user has to be saved already.
32
+ - @doc has to be saved already.
33
+ - @doc will have it's user_id attribute updated immediately.
34
+
35
+ When you do:
36
+
37
+ @user.photos = Photo.all
6
38
 
39
+ - every Photo document will have it's user_id attribute set immediately
40
+
41
+
42
+ == Options
43
+ The available class methods are:
44
+
45
+ For AR:
46
+ belongs_to_mm
47
+ has_one_mm
48
+ has_many_mm
49
+
50
+ For MM:
51
+ belongs_to_ar
52
+ has_one_ar
53
+ has_many_ar
54
+
55
+ All class methods take :foreign_key, :class, and :primary_key options as a hash
56
+
57
+
58
+ == Setup
59
+ Bigamy.setup can take any number of classes as arguments, and can be in an initializer like:
60
+
61
+ Bigamy.setup User, Doc
62
+
63
+
64
+ = License
7
65
  Bigmay is released under the MIT license.
8
66
 
9
- = Support
67
+ It's developed by Ryan Angilly and released with the permission of MyPunchbowl.com
10
68
 
69
+ = Support
11
70
  Just email me at ryan@angilly.com with questions, bugs, or patches.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
data/bigamy.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{bigamy}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ryan Angilly"]
data/lib/bigamy.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'mongo_mapper'
2
+ require 'active_record'
2
3
  require 'set'
3
4
 
4
5
  require 'bigamy/proxy'
@@ -39,15 +40,15 @@ module Bigamy
39
40
  self.bigamy_associations.each {|k,v| v.divorce_everyone }
40
41
  end
41
42
 
42
- def belongs_to_ar name, options = {}, &ext
43
+ def belongs_to_ar name, options = {}
43
44
  bigamy_associations[name] = MongoBelongsTo.new(self, name, options)
44
45
  end
45
46
 
46
- def has_one_ar name, options = {}, &ext
47
+ def has_one_ar name, options = {}
47
48
  bigamy_associations[name] = MongoHasOne.new(self, name, options)
48
49
  end
49
50
 
50
- def has_many_ar name, options = {}, &ext
51
+ def has_many_ar name, options = {}
51
52
  bigamy_associations[name] = MongoHasMany.new(self, name, options)
52
53
  end
53
54
  end
@@ -84,15 +85,15 @@ module Bigamy
84
85
  self.bigamy_associations.each {|k,v| v.divorce_everyone }
85
86
  end
86
87
 
87
- def belongs_to_ar name, options = {}, &ext
88
+ def belongs_to_mm name, options = {}
88
89
  bigamy_associations[name] = ARBelongsTo.new(self, name, options)
89
90
  end
90
91
 
91
- def has_one_ar name, options = {}, &ext
92
+ def has_one_mm name, options = {}
92
93
  bigamy_associations[name] = ARHasOne.new(self, name, options)
93
94
  end
94
95
 
95
- def has_many_ar name, options = {}, &ext
96
+ def has_many_mm name, options = {}
96
97
  bigamy_associations[name] = ARHasMany.new(self, name, options)
97
98
  end
98
99
  end
@@ -34,9 +34,9 @@ class TestArSide < Test::Unit::TestCase
34
34
  assert User.respond_to?(:divorce_everyone)
35
35
  end
36
36
 
37
- context "that has_one_ar :doc" do
37
+ context "that has_one_mm :doc" do
38
38
  setup do
39
- User.has_one_ar :doc
39
+ User.has_one_mm :doc
40
40
  @doc = Doc.create!
41
41
  end
42
42
 
@@ -71,9 +71,9 @@ class TestArSide < Test::Unit::TestCase
71
71
  end
72
72
  end
73
73
 
74
- context "that has_many_ar :doc" do
74
+ context "that has_many_mm :doc" do
75
75
  setup do
76
- User.has_many_ar :docs
76
+ User.has_many_mm :docs
77
77
  end
78
78
 
79
79
  should "create accessors" do
@@ -117,9 +117,9 @@ class TestArSide < Test::Unit::TestCase
117
117
  end
118
118
  end
119
119
 
120
- context "that belongs_to_ar :doc" do
120
+ context "that belongs_to_mm :doc" do
121
121
  setup do
122
- User.belongs_to_ar :doc
122
+ User.belongs_to_mm :doc
123
123
  end
124
124
 
125
125
  should "create accessors" do
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 0
9
- version: 0.1.0
8
+ - 1
9
+ version: 0.1.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ryan Angilly