OSDN Git Service

fix Manifest lst
[pettanr/pettanr.git] / lib / manifest / model / list / has_many_through.rb
index a4e1bd6..21c12df 100644 (file)
@@ -1,53 +1,55 @@
 module Manifest
-  module ListModule
-    class HasManyThroughList < BaseList
-      attr :list, :list_name, :list_manifest, 
-        :belongs_to, :has_many, :has_one
-      
-      def set_default
-        super
-      end
-      
-      def init
-        super
-        return
-        @list_list_conf = @manifest.list(@item_name).lists[list_name] || {}
-        @association_name = @list_list_conf['association_name']
-        @has_many_conf = @manifest.model(@item_name).associations['has_many'] || {}
-        @association_conf = @has_many_conf[@association_name] || {}
-        @association_through_model_name = @association_conf['through']
-        @association_through_model = @association_through_model_name.classify.constantize
-        @association_model_name = @association_conf['model']
-        @association_model = @association_model_name.classify.constantize
-        @foreign_key = @association_conf['foreign_key']
-       if @association_model.content?
-          @owner_model = @association_model.owner_model
-          @owner_table_name = @owner_model.table_name if @owner_model
+  module ModelModule
+    module ListModule
+      class HasManyThroughList < Base
+        attr :list, :list_name, :list_manifest, 
+          :belongs_to, :has_many, :has_one
+        
+        def set_default
+          super
+        end
+        
+        def init
+          super
+          return
+          @list_list_conf = @manifest.list(@item_name).lists[list_name] || {}
+          @association_name = @list_list_conf['association_name']
+          @has_many_conf = @manifest.model(@item_name).associations['has_many'] || {}
+          @association_conf = @has_many_conf[@association_name] || {}
+          @association_through_model_name = @association_conf['through']
+          @association_through_model = @association_through_model_name.classify.constantize
+          @association_model_name = @association_conf['model']
+          @association_model = @association_model_name.classify.constantize
+          @foreign_key = @association_conf['foreign_key']
+         if @association_model.content?
+            @owner_model = @association_model.owner_model
+            @owner_table_name = @owner_model.table_name if @owner_model
+          end
+        end
+        
+        def where root_item
+          w = @association_model.list_where
+          w += ' and ' unless w.blank?
+          [w + @association_through_model.table_name + '.' + @foreign_key + ' = ?', root_item.id] 
+        end
+        
+        def includes
+          {@association_through_model.table_name => {@item_name => {}}}
+        end
+        
+        def items root_item
+           @association_model.where(self.where(root_item)).includes(self.includes).order(self.order).offset(@offset).limit(@page_size)
+        end
+        
+        def paginate root_item
+          Kaminari.paginate_array(Array.new(@association_model.where(self.where(root_item)).includes(self.includes).count, nil)).page(@offset).per(@page_size)
+        end
+        
+        def self.add_action item_name, action_name, list_name, list_conf
+          return
         end
       end
       
-      def where root_item
-        w = @association_model.list_where
-        w += ' and ' unless w.blank?
-        [w + @association_through_model.table_name + '.' + @foreign_key + ' = ?', root_item.id] 
-      end
-      
-      def includes
-        {@association_through_model.table_name => {@item_name => {}}}
-      end
-      
-      def items root_item
-         @association_model.where(self.where(root_item)).includes(self.includes).order(self.order).offset(@offset).limit(@page_size)
-      end
-      
-      def paginate root_item
-        Kaminari.paginate_array(Array.new(@association_model.where(self.where(root_item)).includes(self.includes).count, nil)).page(@offset).per(@page_size)
-      end
-      
-      def self.add_action item_name, action_name, list_name, list_conf
-        return
-      end
     end
-    
   end
 end