kronn-has_many_polymorphs 3.0.1 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -44,7 +44,7 @@ module ActiveRecord #:nodoc:
44
44
  end
45
45
 
46
46
  def construct_scope
47
- _logger_warn "Warning; not all usage scenarios for polymorphic scopes are supported yet."
47
+ # _logger_warn "Warning; not all usage scenarios for polymorphic scopes are supported yet."
48
48
  super
49
49
  end
50
50
 
@@ -410,9 +410,10 @@ module ActiveRecord #:nodoc:
410
410
  options[:as] = reflection.options[:as]
411
411
  end
412
412
 
413
- has_many(reflection.options[:through], options)
414
-
415
- inject_before_save_into_join_table(association_id, reflection)
413
+ unless reflections[reflection.options[:through]]
414
+ has_many(reflection.options[:through], options)
415
+ inject_before_save_into_join_table(association_id, reflection)
416
+ end
416
417
  end
417
418
 
418
419
  def inject_before_save_into_join_table(association_id, reflection)
@@ -447,21 +448,22 @@ module ActiveRecord #:nodoc:
447
448
  # no way to traverse to a double polymorphic parent
448
449
  # (TODO is that right?)
449
450
  unless reflection.options[:is_double] or reflection.options[:conflicts].include? self.name.tableize.to_sym
450
-
451
451
  # the join table
452
452
  through = "#{reflection.options[:through]}#{'_as_child' if parent == self}".to_sym
453
- has_many(through,
454
- :as => association_id._singularize,
455
- # :source => association_id._singularize,
456
- # :source_type => reflection.options[:polymorphic_type_key],
457
- :class_name => reflection.klass.name,
458
- :dependent => reflection.options[:dependent],
459
- :extend => reflection.options[:join_extend],
460
- # :limit => reflection.options[:limit],
461
- # :offset => reflection.options[:offset],
462
- :order => devolve(association_id, reflection, reflection.options[:parent_order], reflection.klass),
463
- :conditions => devolve(association_id, reflection, reflection.options[:parent_conditions], reflection.klass)
464
- )
453
+ unless reflections[through]
454
+ has_many(through,
455
+ :as => association_id._singularize,
456
+ # :source => association_id._singularize,
457
+ # :source_type => reflection.options[:polymorphic_type_key],
458
+ :class_name => reflection.klass.name,
459
+ :dependent => reflection.options[:dependent],
460
+ :extend => reflection.options[:join_extend],
461
+ # :limit => reflection.options[:limit],
462
+ # :offset => reflection.options[:offset],
463
+ :order => devolve(association_id, reflection, reflection.options[:parent_order], reflection.klass),
464
+ :conditions => devolve(association_id, reflection, reflection.options[:parent_conditions], reflection.klass)
465
+ )
466
+ end
465
467
 
466
468
  # the association to the target's parents
467
469
  association = "#{reflection.options[:as]._pluralize}#{"_of_#{association_id}" if reflection.options[:rename_individual_collections]}".to_sym
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kronn-has_many_polymorphs
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 3
5
5
  prerelease: false
6
6
  segments:
7
7
  - 3
8
8
  - 0
9
- - 1
10
- version: 3.0.1
9
+ - 2
10
+ version: 3.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Evan Weaver
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2010-10-21 00:00:00 +02:00
20
+ date: 2010-10-27 00:00:00 +02:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency