Method: ActiveScaffold::Finder::ClassMethods#type_casted_tokens

Defined in:
lib/active_scaffold/finder.rb

#type_casted_tokens(tokens, columns, like_pattern) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/active_scaffold/finder.rb', line 29

def type_casted_tokens(tokens, columns, like_pattern)
  tokens.map do |value|
    columns.each_with_object({}) do |column, column_tokens|
      column_tokens[column.name] =
        if column.text?
          like_pattern.sub('?', column.active_record? ? column.active_record_class.sanitize_sql_like(value) : value)
        else
          ActiveScaffold::Core.column_type_cast(value, column.column)
        end
    end
  end
end