bigamy 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.2.0
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.2"
8
+ s.version = "0.2.0"
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
@@ -24,8 +24,11 @@ module Bigamy
24
24
 
25
25
  module Base
26
26
  def self.configure(model)
27
- model.class_inheritable_accessor :bigamy_associations
28
- model.bigamy_associations = {}
27
+ class << model
28
+ def bigamy_associations
29
+ @bigamy_associations ||= {}
30
+ end
31
+ end
29
32
  end
30
33
  end
31
34
 
@@ -38,6 +41,7 @@ module Bigamy
38
41
  module ClassMethods
39
42
  def divorce_everyone
40
43
  self.bigamy_associations.each {|k,v| v.divorce_everyone }
44
+ self.bigamy_associations.clear
41
45
  end
42
46
 
43
47
  def belongs_to_ar name, options = {}
@@ -57,7 +61,7 @@ module Bigamy
57
61
  def set_value c, val
58
62
  write_key c, val
59
63
  end
60
-
64
+
61
65
  def read_val c
62
66
  read_key c
63
67
  end
@@ -70,6 +74,12 @@ module Bigamy
70
74
  i
71
75
  end
72
76
  end
77
+
78
+ module PluginAddition
79
+ def self.included(model)
80
+ model.plugin Bigamy::Mongo
81
+ end
82
+ end
73
83
  end
74
84
 
75
85
  module ActiveRecord
@@ -83,6 +93,7 @@ module Bigamy
83
93
  module ClassMethods
84
94
  def divorce_everyone
85
95
  self.bigamy_associations.each {|k,v| v.divorce_everyone }
96
+ self.bigamy_associations.clear
86
97
  end
87
98
 
88
99
  def belongs_to_mm name, options = {}
@@ -102,7 +113,7 @@ module Bigamy
102
113
  def set_value c, val
103
114
  self[c] = val
104
115
  end
105
-
116
+
106
117
  def read_val c
107
118
  read_attribute c
108
119
  end
@@ -118,3 +129,6 @@ module Bigamy
118
129
  end
119
130
 
120
131
  end
132
+
133
+ MongoMapper::Document.append_inclusions(Bigamy::Mongo::PluginAddition)
134
+ Bigamy::ActiveRecord.configure(ActiveRecord::Base)
@@ -22,10 +22,6 @@ class TestArSide < Test::Unit::TestCase
22
22
  end
23
23
 
24
24
  context "User" do
25
- setup do
26
- Bigamy.setup User, Doc
27
- end
28
-
29
25
  teardown do
30
26
  User.divorce_everyone
31
27
  end
@@ -24,10 +24,6 @@ class TestMongoSide < Test::Unit::TestCase
24
24
  end
25
25
 
26
26
  context "Doc" do
27
- setup do
28
- Bigamy.setup Doc, User
29
- end
30
-
31
27
  teardown do
32
28
  Doc.divorce_everyone
33
29
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
8
7
  - 2
9
- version: 0.1.2
8
+ - 0
9
+ version: 0.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ryan Angilly