OSDN Git Service

creditable
[pettanr/pettanr.git] / lib / peta / item.rb
index c738aaa..8025da9 100644 (file)
@@ -1,6 +1,7 @@
 module Peta
   class Item < ActiveRecord::Base
     self.abstract_class = true
+    attr :boosters
     
     # Dynamic ClassMethods
     
@@ -75,6 +76,14 @@ module Peta
       self.plural.underscore
     end
     
+    def self.find_boost_name column_name
+      self.my_peta.find_boost_name column_name
+    end
+    
+    def self.extend_column? column_name
+      self.my_peta.extend_column? column_name
+    end
+    
     def self.visible_count_options
       nil
     end
@@ -99,7 +108,7 @@ module Peta
       opt = {}
       opt.merge!(self.show_opt)
       item = self.find(item_id, opt)
-      item.boosts 'show'
+      item.boosts 'read'
       raise ActiveRecord::Forbidden unless item.visible?(operators)
       item
     end
@@ -158,7 +167,23 @@ module Peta
     end
     
     def boosts level
-      self.class.my_peta.boosts self, level
+      self.class.my_peta.boost.each do |boost_name, boost_manifest|
+        next if level == 'read' and boost_manifest.level == 'post'
+        self.boost boost_manifest
+      end
+    end
+    
+    def boost boost_manifest
+      @boosters ||= {}
+      @boosters[boost_manifest.name] = Locmare::Booster.new(boost_manifest, self)
+    end
+    
+    def boosters
+      @boosters
+          end
+    
+    def extend_column? column_name
+      self.class.extend_column? column_name
     end
     
     def supply_default