Module: ActiveScaffold::Finder::ClassMethods::Mongoid
- Defined in:
- lib/active_scaffold/finder.rb
Instance Method Summary collapse
Instance Method Details
#create_conditions_for_columns(tokens, columns) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# 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) ⇒ Object
86 87 88 89 90 91 92 93 |
# 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 |