Add the has_many_polymorphs plugin
[cs356-p2-videostore.git] / vendor / plugins / has_many_polymorphs / test / models / beautiful_fight_relationship.rb
1
2 require 'extension_module'
3
4 class BeautifulFightRelationship < ActiveRecord::Base
5   set_table_name 'keep_your_enemies_close'
6
7   belongs_to :enemy, :polymorphic => true
8   belongs_to :protector, :polymorphic => true
9   # polymorphic relationships with column names different from the relationship name
10   # are not supported by Rails
11   
12   acts_as_double_polymorphic_join :enemies => [:dogs, :kittens, :frogs], 
13     :protectors =>  [:wild_boars, :kittens, :"aquatic/fish", :dogs],
14     :enemies_extend => [ExtensionModule, proc {}],
15     :protectors_extend => proc {
16       def a_method
17         :correct_proc_result
18       end
19     },
20     :join_extend => proc {
21       def a_method
22         :correct_join_result                                                                                                            
23       end
24     }
25 end
26