Class/Module Index [+]

Quicksearch

Padrino::Contrib::Orm::MongoMapper::Search::ClassMethods

Public Instance Methods

has_search(*fields) click to toggle source
# File lib/padrino-contrib/orm/mongo_mapper/search.rb, line 21
def has_search(*fields)
  @_search_fields = fields
end
search(text, options={}) click to toggle source
# File lib/padrino-contrib/orm/mongo_mapper/search.rb, line 25
def search(text, options={})
  if text
    re    = Regexp.new(Regexp.escape(text), 'i')
    where = @_search_fields.map { |field| "this.#{field}.match(#{re.inspect})" }.join(" || ")
    options.merge!("$where" => where)
  end
  options.delete(:paginate) ? paginate(options) : all(options)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.