596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
|
# File 'lib/mongoid-fts.rb', line 596
def Mixin.code
@code ||= proc do
class << self
def search(*args, &block)
options = Map.options_for!(args)
options[:model] = self
args.push(options)
FTS.search(*args, &block)
end
def _search(*args, &block)
options = Map.options_for!(args)
options[:model] = self
args.push(options)
FTS.search(*args, &block)
end
end
after_save do |model|
FTS::Index.add(model) rescue nil
end
after_destroy do |model|
FTS::Index.remove(model) rescue nil
end
has_one(:search_index, :as => :context, :class_name => '::Mongoid::FTS::Index')
end
end
|