class Manifest
cattr_accessor :manifest
attr :system_resources, :magic_numbers,
- :controllers, :models, :lists, :profilers, :filers, :forms, :lists, :views
+ :controllers, :models
# call me before load routes.rb
# routes.rb needs engine_resources manifest in system_resources
# ex. it's adding license_groups routes
- def initialize manifest
- @manifest = manifest || {}
- @system_resources = SystemResource.new(self, SystemResource.set_default(@manifest['system_resources']))
- @magic_numbers = @manifest['magic_numbers']
+ def initialize global_json
+ @global_json = global_json || {}
+ @system_resources = SystemResource.new(self, SystemResource.set_default(@global_json['system_resources']))
+ @magic_numbers = @global_json['magic_numbers']
end
def init
# managers can't initialize before load application.rb
return unless defined? ::Pettanr
- @controllers = Controller.manager(self, @manifest['controllers'])
- @models = Model.manager(self, @manifest['models'])
- @locals = @manifest['locals']
- @filers = Filer.manager(self, @locals['filers'])
- @profilers = Profiler.manager(self, @locals['profilers'])
- @forms = Form.base_manager(self, @locals['forms'])
- @forms.merge(Form.extend_manager(self, @locals['forms']))
- @lists = List.manager(self, @locals['lists'])
+ @controllers = Controller.manager(self, @global_json['controllers'] || {})
+ @models = Model.manager(self, @global_json['models'] || {})
+ end
+
+ def system_resources_init
@system_resources.init
- add_action
end
- def add_action
- return
- @controllers.each do |controller_name, controller|
- model_name = controller.model_name
- next if model_name.blank?
- controller.actions.each do |action_name, conf|
- next unless conf['type'] == 'list'
- list_name = conf['list']['list_name']
- list = Pettanr::Application::manifest.list_managers[model_name]
- list.add_action action_name, list_name
- end
+ def load_models_manifest
+ @models.each do |model_name, model|
+ model.classify.load_manifest
end
end
Manifest.manifest
end
- def load json
- Manifest.manifest = Manifest.new json
+ def load global_json
+ Manifest.manifest = Manifest.new global_json
end
def item_name_to_model item_name
name.singularize
end
+ def pluralize name
+ name.pluralize
+ end
+
end
extend ModuleMethods