acts-as-joinable 0.1.6.2 → 0.1.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/Rakefile +1 -1
  2. data/lib/acts_as_joinable/core.rb +7 -4
  3. metadata +3 -3
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.6.2"
8
+ s.version = "0.1.6.3"
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"
@@ -181,12 +181,13 @@ module ActsAsJoinable
181
181
  #send(relationship_with_context).delete_all
182
182
 
183
183
  #send(relationship_with_context).delete_all
184
- #send(plural_type).each do |object|
185
- # send(plural_type).delete(object)
186
- #end
184
+
187
185
  unless value.blank?
188
186
  send(plural_type) << value
189
187
  end
188
+ send(plural_type).each do |object|
189
+ send(plural_type).delete(object) unless object.id == value.id
190
+ end
190
191
  end
191
192
  define_method "#{singular_type}_id" do
192
193
  send(singular_type).id rescue nil
@@ -198,7 +199,9 @@ module ActsAsJoinable
198
199
  end
199
200
 
200
201
  def add_association(relationship, plural_type, options, join_context, join_value, nestable, &block)
201
- eval_options = {:context => join_context}
202
+ eval_options = {}
203
+ eval_options[:context] = join_context unless join_context.to_s == options[:class_name].to_s.underscore.singularize
204
+
202
205
  eval_options[:value] = join_value unless join_value.blank?
203
206
  # has_many :users, :through => :child_relationships
204
207
  plural_relationship = "#{relationship}_#{plural_type}".to_sym
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: 91
4
+ hash: 89
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
9
  - 6
10
- - 2
11
- version: 0.1.6.2
10
+ - 3
11
+ version: 0.1.6.3
12
12
  platform: ruby
13
13
  authors:
14
14
  - Lance Pollard