+ManifestBase.require_modules "manifest/controller/",
+ %w|action|
-module Pettanr
- class ControllerManager
- class ActionList
- def initialize action_name, item_name, operators, list, conf, manifest
- @action_name = action_name
- @item_name = item_name
- @operators = operators
- @list = list
- @conf = conf
- @manifest = manifest
- end
-
- def items
- @items ||= @list.items
- end
-
- def filer
- @filer ||= @manifest.filer_managers[@item_name].open(@item_name, @items, @operators, @list.paginate)
- end
-
- end
-
- class ActionShow
- def initialize action_name, item_name, conf, manifest
- @action_name = action_name
- @item_name = item_name
- @conf = conf
- @manifest = manifest
-
- end
-
- end
+module Manifest
+ class Controller < ManifestBase::Base
+ include ControllerModule
+ attr :actions
- attr :controller_manifest, :item_name, :manifest, :controller_conf,
- :actions
- @@types = {'list' => ActionList, 'show' => ActionShow}
- def initialize controller_manifest
- @controller_manifest = controller_manifest
- @item_name = @controller_manifest.item_name
- @manifest = @controller_manifest.manifest
- @controller_conf = @controller_manifest.conf
- @actions = {}
- @controller_manifest.actions.each {|action_name, conf|
- type = conf['type']
- @actions[action_name] = @@types[type]
- }
+ def set_default
+ super
+ @json['actions'] ||= {}
end
- def open action_name, params, operators
- name = if @controller_manifest.actions[action_name]['item_name']
- @controller_manifest.actions[action_name]['item_name']
- else
- @item_name
- end
- list_name = @controller_manifest.list_name action_name
- @list = @manifest.list_managers[name].open(list_name, params[:page], params[:page_size], operators)
- @actions[action_name].new action_name, name, operators, @list, @controller_conf, @manifest
+ def init
+ super
+ @actions = ManifestBase.load_type_name_args self, @json, 'actions', ActionFactory
end
end
end
-