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