OSDN Git Service

separate manifest
[pettanr/pettanr.git] / lib / local_manifest / local_manifest.rb
1 module LocalManifest
2   class LocalManifest
3     cattr_accessor :manifest
4     attr :list_groups, :profilers, :filers, :forms
5     # call me before load routes.rb
6     # routes.rb needs engine_resources manifest in system_resources
7     # ex. it's adding license_groups routes
8     def initialize local_json
9       @local_json = local_json || {}
10     end
11     
12     def init
13       # managers can't initialize before load  application.rb
14       return unless defined? ::Pettanr
15       @list_groups = ListGroup.manager(self, @local_json['list_groups'] || {})
16       @filers = Filer.manager(self, @local_json['filers'] || {})
17       @profilers = Profiler.manager(self, @local_json['profilers'] || {})
18       @forms = Form.base_manager(self, @local_json['forms'] || {})
19       @forms.merge(Form.extend_manager(self, @local_json['forms'] || {}))
20     end
21     
22   end
23   
24   module ModuleMethods
25     def manifest
26       LocalManifest.manifest
27     end
28     
29     def load local_json
30       LocalManifest.manifest = LocalManifest.new local_json
31     end
32     
33   end
34
35   extend ModuleMethods
36 end
37