OSDN Git Service

change form manifest
[pettanr/pettanr.git] / lib / manifest / controller.rb
index 6f26f45..a2d55b0 100644 (file)
+ManifestBase.require_modules "manifest/controller/", 
+  %w|action|
 
-module Pettanr
-  module Manifest
-    class Controller
-      def self.set_default my_manifest
-        my_manifest.each {|item_name, controller_manifest|
-          controller_manifest|['model_name'] ||= item_name
-          controller_manifest|['actions'] ||= {}
-          controller_manifest|['actions'].each {|action_name, action_manifest|
-            action_manifest['options'] ||= {}
-            action_manifest['options'].each {option_name, option_manifest|
-              raise "undefined list_name for controllers > #{item_name} > actions > #{action_name} > options\n" unless option_manifest['list_name']
-            }
-          }
-        }
-      end
-      
-      class ActionList
-        attr :list
-        def initialize my_item_name, action_name, conf
-          # get home list_name
-          @my_item_name = conf['item_name'] if conf['item_name']
-          @action_name = action_name
-          @conf = conf
-        end
-        
-        def list params, operators
-          list_name = @controller_manifest.list_name action_name
-          @list = @manifest.list_managers[@my_item_name].open(list_name, params[:page], params[:page_size], operators)
-        end
-        
-        def ready params, operators
-          @items = @action.items 
-          
-        end
-        
-        def exec
-        end
-        
-        def render
-          format.html {
-            @filer = @action.filer
-            render :template => 'system/filer', :locals => {
-              :filer => @filer
-            }
-          }
-        end
-        
-        def cook params, operators
-          @action.ready params, operators
-          @action.exec
-          @action.render
-        end
-        
-      end
-      
-      class ActionShow
-        def initialize my_item_name, action_name, conf
-          @my_item_name = conf['item_name'] if conf['item_name']
-          @action_name = action_name
-          @conf = conf
-        end
-        
-        def ready
-          @item = Comic.show(params[:id], @operators)
-        end
-        
-        def exec
-        end
-        
-        def render
-          format.html {
-          }
-        end
-        
-      end
-      
-      class Recipe
-      end
-      
-      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 = {}
-        @my_item_name = @controller_conf['item_name'] || @item_name
-        @controller_manifest.actions.each {|action_name, conf|
-          type = conf['type']
-          @actions[action_name] = @@types[type].new @my_item_name, action_name, conf
-        }
-      end
-      
-      
+module Manifest
+  class Controller < ManifestBase::Base
+    include ControllerModule
+    attr :actions
+    
+    def set_default
+      super
+      @json['actions'] ||= {}
     end
+    
+    def init
+      super
+      @actions = ManifestBase.load_type_name_args self, @json, 'actions', ActionFactory
+    end
+    
   end
 end
-