OSDN Git Service

Merge branch 'v06' of git.sourceforge.jp:/gitroot/pettanr/pettanr into v06
[pettanr/pettanr.git] / app / models / speech_balloon_template.rb
index 5217f5d..4660b97 100644 (file)
@@ -11,6 +11,26 @@ class SpeechBalloonTemplate < Peta::Template
   validates :system_picture_id, :presence => true, :numericality => true, :existence => {:both => false}
   validates :settings, :presence => true
   
+  scope :find_index, -> do
+    self
+  end
+  
+  scope :find_by_original_picture, -> (original_picture_id) do 
+    find_index.where(original_picture_id: original_picture_id)
+  end
+  
+  scope :with_panels, -> do
+    includes(speech_balloons: panel)
+  end
+  
+  scope :find_by_panel, -> (panel_id) do 
+    with_panels.where(Panel.arel_table[:id].eq panel_id).references(:panel)
+  end
+  
+  scope :find_by_system_picture, -> (system_picture_id) do 
+    find_index.where(system_picture_id: system_picture_id)
+  end
+  
   def supply_default
   end