st-elsewhere 0.1.1 → 0.1.2
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.rdoc +6 -1
- data/VERSION +1 -1
- data/lib/st-elsewhere.rb +3 -3
- data/st-elsewhere.gemspec +3 -2
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -22,6 +22,8 @@ St. Elsewhere adds a new class method (<tt>has_many_elsewhere</tt>) to support b
|
|
22
22
|
|
23
23
|
Example:
|
24
24
|
|
25
|
+
http://emphaticsolutions.com/images/has_many_elsewhere.png
|
26
|
+
|
25
27
|
class Hospital < AcitveRecord::Base
|
26
28
|
has_many :hospital_doctors
|
27
29
|
has_many_elsewhere :doctors, :through => :hospital_doctors
|
@@ -47,4 +49,7 @@ Example:
|
|
47
49
|
|
48
50
|
=== Inefficiencies
|
49
51
|
|
50
|
-
<tt>has_many_elsewhere</tt> is certainly much less efficient than a comparable has_many relationship. <tt>has_many :through</tt> relationships use SQL JOINs which while efficient, do not work across multiple database connections. St. Elsewhere implements much of the same resulting API methods in code, using less efficient SQL.
|
52
|
+
<tt>has_many_elsewhere</tt> is certainly much less efficient than a comparable has_many relationship. <tt>has_many :through</tt> relationships use SQL JOINs which while efficient, do not work across multiple database connections. St. Elsewhere implements much of the same resulting API methods in code, using less efficient SQL.
|
53
|
+
|
54
|
+
=== Install from gemcutter
|
55
|
+
gem install st-elsewhere
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/lib/st-elsewhere.rb
CHANGED
@@ -71,7 +71,7 @@ module StElsewhere
|
|
71
71
|
removed_associations = current_associations - new_associations
|
72
72
|
new_associations = new_associations - current_associations
|
73
73
|
|
74
|
-
self.send("remove_#{association_singular}_associations",
|
74
|
+
self.send("remove_#{association_singular}_associations", through_class, removed_associations)
|
75
75
|
self.send("add_#{association_singular}_associations", through_class, association_id, new_associations)
|
76
76
|
end
|
77
77
|
|
@@ -89,8 +89,8 @@ module StElsewhere
|
|
89
89
|
|
90
90
|
# Hospital#add_doctor_associations (private)
|
91
91
|
define_method("add_#{association_singular}_associations") do |through_class, association_id, associations|
|
92
|
-
myself =
|
93
|
-
my_buddy =
|
92
|
+
myself = self.class.to_s.foreign_key
|
93
|
+
my_buddy = association_singular.foreign_key
|
94
94
|
associations.each do |association|
|
95
95
|
my_buddy_id = Fixnum.eql?(association.class) ? association : association.id
|
96
96
|
new_association = through_class.new(myself => self.id, my_buddy => my_buddy_id)
|
data/st-elsewhere.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{st-elsewhere}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Brian Doll"]
|
12
|
-
s.date = %q{2009-11-
|
12
|
+
s.date = %q{2009-11-16}
|
13
13
|
s.description = %q{This gem provides has_many_elsewhere, an ActiveRecord class method to support many to many relationships in Rails applications, across multiple database connections.}
|
14
14
|
s.email = %q{brian@emphaticsolutions.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
"Rakefile",
|
22
22
|
"VERSION",
|
23
23
|
"lib/st-elsewhere.rb",
|
24
|
+
"st-elsewhere.gemspec",
|
24
25
|
"tasks/st-elsewhere_tasks.rake",
|
25
26
|
"test/st-elsewhere_test.rb",
|
26
27
|
"test/test_helper.rb"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: st-elsewhere
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Doll
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-16 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|