Sha256: 73c4b37d1ff67f4a35205939c1fa14be0e8c070f4b26e630dc3e7f9216a48707

Contents?: true

Size: 781 Bytes

Versions: 1

Compression:

Stored size: 781 Bytes

Contents

# encoding: utf-8

module XapianDb
  module Adapters

    # base class for all adapters.
    # This adapter does the following:
    # - adds the class method <code>search(expression)</code> to an indexed class
    # @author Gernot Kogler

     class BaseAdapter

       class << self

         # Implement the class helper methods
         # @param [Class] klass The class to add the helper methods to
         def add_class_helper_methods_to(klass)

           klass.class_eval do

             # Add a method to search models of this class
             define_singleton_method(:search) do |expression|
               XapianDb.database.search "indexed_class:#{klass.name.downcase} and (#{expression})"
             end

           end
         end
       end
     end
   end
 end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
xapian_db-0.3.4 lib/xapian_db/adapters/base_adapter.rb