Method: Whistlepig::Query#term_map

Defined in:
ext/whistlepig/whistlepig.c

#term_mapObject

Returns a new query that’s the result of applying the block to each word in the query. Useful for transforming queries programmatically after they’ve been parsed.



393
394
395
396
397
398
399
400
401
402
403
404
405
# File 'ext/whistlepig/whistlepig.c', line 393

static VALUE query_map_terms(VALUE self) {
  char buf[1024];

  wp_query* query; Data_Get_Struct(self, wp_query, query);
  wp_query* result = wp_query_substitute(query, yielding_substituter);

  VALUE o_query = Data_Wrap_Struct(c_query, NULL, wp_query_free, result);

  VALUE argv[1] = { rb_iv_get(self, "@query")  };
  rb_obj_call_init(o_query, 1, argv);

  return o_query;
}