OSDN Git Service

add seigas controller
[tdcgexplorer/nimono.git] / app / models / seiga.rb
index e099399..5812c70 100644 (file)
@@ -1,2 +1,27 @@
 class Seiga < ActiveGroonga::Base
+  def self.search(search)
+    if search.text.blank?
+      all
+    else
+      select { |rec|
+        rec.match(search.text) { |mat|
+          (mat.title * 1) | (mat.description * 1)
+        }
+      }
+    end
+  end
+
+  def image_id
+    key
+  end
+
+  class Search
+    attr_accessor :text
+
+    def initialize(attributes)
+      attributes.each do |name, value|
+        send("#{name}=", value)
+      end if attributes
+    end
+  end
 end