Sha256: 68065f9ba400c0ab8800c21a5b70c38f9746975ab85c3f2a8a9faf064a3a7df7

Contents?: true

Size: 551 Bytes

Versions: 6

Compression:

Stored size: 551 Bytes

Contents

module Glue

# Search support for Og managed classes.

module Searchable

  def self.included(base)
    base.extend(ClassMethods)
  end
  
  module ClassMethods
    
    # Override this method in your class to customize the
    # search. This is a nice default method.
    
    def search(query)
      search_props = properties.values.select { |p| p.searchable }
      condition = search_props.collect { |p| "#{p} LIKE '%#{query}%'" }.join(' OR ') 
      all(:condition => condition)
    end
  
  end
  
end

end

# * George Moschovitis <gm@navel.gr>

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
og-0.26.0 lib/glue/searchable.rb
og-0.27.0 lib/glue/searchable.rb
og-0.28.0 lib/glue/searchable.rb
og-0.29.0 lib/glue/searchable.rb
og-0.30.0 lib/glue/searchable.rb
og-0.31.0 lib/glue/searchable.rb