Module: ActsAsXapian::ClassMethods

Defined in:
lib/acts_as_xapian/base.rb

Instance Method Summary collapse

Instance Method Details

#find_with_xapian(search_term, options = {}) ⇒ Object

Model.find_with_xapian(“Search Term OR Phrase”)

> Array of Records

this can be used through association proxies /!\ DANGEROUS MAGIC /!\ example: as seen here: pastie.org/270114



96
97
98
# File 'lib/acts_as_xapian/base.rb', line 96

def find_with_xapian(search_term, options = {})
  search_with_xapian(search_term, options).results.map {|x| x[:model] }
end

#search_with_xapian(search_term, options = {}) ⇒ Object



100
101
102
# File 'lib/acts_as_xapian/base.rb', line 100

def search_with_xapian(search_term, options = {})
  ActsAsXapian::Search.new([self], search_term, options)
end

#with_xapian_scope(ids) ⇒ Object



104
105
106
# File 'lib/acts_as_xapian/base.rb', line 104

def with_xapian_scope(ids)
  with_scope(:find => {:conditions => {"#{self.table_name}.#{self.primary_key}" => ids}, :include => self.xapian_options[:eager_load]}) { yield }
end

#xapian?Boolean

this method should return true if the integration of xapian on self is complete

Returns:

  • (Boolean)


109
110
111
# File 'lib/acts_as_xapian/base.rb', line 109

def xapian?
  self.included_modules.include?(InstanceMethods) && self.extended_by.include?(ClassMethods)
end