Sha256: b374b69e7a7ca2123a6b312203f6c0ab6758fc37a151cbbd2c0b3386e151a8a3
Contents?: true
Size: 905 Bytes
Versions: 1
Compression:
Stored size: 905 Bytes
Contents
module Dusen module ActiveRecord def search_syntax(&dsl) @dusen_syntax = Dusen::Description.read_syntax(&dsl) singleton_class.send(:define_method, :search) do |query_string| @dusen_syntax.search(self, query_string) end end def where_like(conditions) scope = self conditions.each do |field_or_fields, query| fields = Array(field_or_fields).collect do |field| Util.qualify_column_name(scope, field) end query_with_placeholders = fields.collect { |field| "#{field} LIKE ?" }.join(' OR ') like_expression = Dusen::Util.like_expression(query) bindings = [like_expression] * fields.size conditions = [ query_with_placeholders, *bindings ] scope = Util.append_scope_conditions(scope, conditions) end scope end end end ActiveRecord::Base.send(:extend, Dusen::ActiveRecord)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dusen-0.1.0 | lib/dusen/active_record_ext.rb |