acts-as-joinable 0.1.7.4 → 0.1.7.5

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/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'rake/gempackagetask'
5
5
  spec = Gem::Specification.new do |s|
6
6
  s.name = "acts-as-joinable"
7
7
  s.authors = ["Lance Pollard"]
8
- s.version = "0.1.7.4"
8
+ s.version = "0.1.7.5"
9
9
  s.summary = "ActsAsJoinable: DRYing up Many-to-Many Relationships in ActiveRecord"
10
10
  s.homepage = "http://github.com/viatropos/acts-as-joinable"
11
11
  s.email = "lancejpollard@gmail.com"
@@ -1,3 +1,17 @@
1
1
  class ActsAsJoinable::Relationship < ActiveRecord::Base
2
2
  acts_as_relationship
3
- end
3
+
4
+ def swap_parent_and_child
5
+ old_parent_type = self.parent_type
6
+ old_parent_id = self.parent_id
7
+ old_child_type = self.child_type
8
+ old_child_id = self.child_id
9
+
10
+ self.parent_type = old_child_type
11
+ self.parent_id = old_child_id
12
+ self.child_type = old_parent_type
13
+ self.child_id = old_parent_id
14
+
15
+ self.save!
16
+ end
17
+ end
@@ -133,6 +133,10 @@ module ActsAsJoinable
133
133
  # condition_string << "(#{relationship_table}.#{relationship}_type IN (?))"
134
134
  if join_context == class_name.underscore# && opposite_for(relationship).to_sym != :child
135
135
  #conditions = [condition_string, [class_name]]
136
+ # if join_value
137
+ # condition_string << "(#{relationship_table}.value = ?)"
138
+ # conditions = [condition_string, join_value.to_s]
139
+ # end
136
140
  else
137
141
  condition_string << "(#{relationship_table}.context IN (?))"
138
142
  condition_string << " AND (#{relationship_table}.value = ?)" if join_value
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts-as-joinable
3
3
  version: !ruby/object:Gem::Version
4
- hash: 83
4
+ hash: 81
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
9
  - 7
10
- - 4
11
- version: 0.1.7.4
10
+ - 5
11
+ version: 0.1.7.5
12
12
  platform: ruby
13
13
  authors:
14
14
  - Lance Pollard
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-10-15 00:00:00 -05:00
19
+ date: 2010-10-17 00:00:00 -05:00
20
20
  default_executable:
21
21
  dependencies: []
22
22