module ActiveScaffold::Finder::ClassMethods::Mongoid

Public Instance Methods

create_conditions_for_columns(tokens, columns) click to toggle source
# File lib/active_scaffold/finder.rb, line 70
def create_conditions_for_columns(tokens, columns)
  conditions = tokens.map do |columns_token|
    token_conditions = columns.map do |column|
      value = columns_token[column.name]
      value = /#{value}/ if column.text?
      column.search_sql.map do |search_sql|
        # call .to_s so String is returned from CowProxy::String in threadsafe mode
        # in other case, or method from Mongoid would fail
        {search_sql.to_s => value}
      end
    end.flatten
    active_scaffold_config.model.or(token_conditions).selector
  end
  [active_scaffold_config.model.and(conditions).selector]
end
like_pattern(text_search) click to toggle source
# File lib/active_scaffold/finder.rb, line 86
def like_pattern(text_search)
  case text_search
  when :full then '?'
  when :start then '^?'
  when :end then '?$'
  else '^?$'
  end
end