OSDN Git Service

rename model name
[pettanr/pettanr.git] / lib / local_manifest / profiler / association / has_many.rb
1 module LocalManifest
2   module ProfilerModule
3     module AssociationModule
4       class HasMany < ManifestBase::Names
5         attr :controller_name, :item_name, :action_name
6         
7         def set_default
8           super
9         end
10         
11         def init
12           super
13           if list_manifest = self.profiler.lists[@name]
14             @controller_name = list_manifest.controller_name
15             @action_name = list_manifest.action_name
16           else
17             n = @name.split '.'
18             if n.size > 1
19               @controller_name = n[0]
20               @action_name = n[1]
21             else
22               ManifestBase::alert_undefined_message 'list', self.module_message
23             end
24           end
25         end
26         
27         def model
28           item_name = Manifest.manifest.controllers[@controller_name].actions[@action_name].item_name
29           ::Manifest::item_name_to_model item_name
30         end
31         
32         def association_name
33           @parent.profiler_name
34         end
35         
36         def profiler
37           @parent.profiler
38         end
39         
40         def profiler_manifest
41           @parent.profiler_manifest
42         end
43         
44       end
45       
46     end
47   end
48 end