class Manifest _module_names = null module_names: () -> _module_names init: () -> # managers can't initialize before load application.rb @inflectors = @global_json.inflectors @item_names = {} @table_names = {} _.each @inflectors, (table_name, item_name) => @item_names[item_name] = table_name # monkey copy @table_names[table_name] = item_name @items = ManifestBase.load_type_name_args(this, @global_json, 'items', Manifest.ItemFactory) @controllers = Manifest.Controller.load(this, @global_json, 'controllers', Manifest.Controller) @models = Manifest.Model.load(this, @global_json, 'models', Manifest.Model) @replace_action_alias() true replace_action_alias: () -> replaces = {} _.each @controllers, (controller_manifest, controller_name) -> _.each controller_manifest.actions, (action_manifest, action_name) -> return if not action_manifest.alias alias_action = action_manifest.alias_action() return if alias_action.type != action_manifest.type args = {} _.each action_manifest.a_arg_names(), (name) -> args[name] = action_manifest[name] || alias_action[name] _.each action_manifest.b_arg_names(), (name) -> args[name] = alias_action[name] || action_manifest[name] args.original = action_manifest json = {type: alias_action.type, args: args} new_action_manifest = Manifest.ControllerModule.ActionFactory.factory( controller_manifest, action_manifest.name, json, action_manifest.module_name, Manifest.ControllerModule.ActionFactory ) replaces[controller_name] ||= {} replaces[controller_name][action_name] = new_action_manifest _.each replaces, (controller, controller_name) -> _.each controller, (action_manifest, action_name) -> Manifest.manifest().controllers[controller_name].actions[action_name] = action_manifest pluralize: (item_name) -> @item_names[item_name] singularize: (table_name) -> @table_names[table_name] @item_name_to_model: (item_name) -> Pettanr[Pettanr.camelize(item_name)] @manifest: () -> @mani @set_manifest: (manifest) -> @mani = manifest constructor: (global_json) -> _module_names = [] @global_json = global_json || {} @system_resources = new Manifest.SystemResource( this, Manifest.SystemResource.set_default(@global_json['system_resources']) ) @magic_numbers = @global_json['magic_numbers'] @items = {} @controllers = {} @models = {} @Manifest = Manifest