Sha256: 3b851af162f25e9166e79b7453297ccfadefcbe844584b13530443fcfc2526fa
Contents?: true
Size: 972 Bytes
Versions: 2
Compression:
Stored size: 972 Bytes
Contents
module Dusen module ActiveRecord def search_syntax(&dsl) if dsl @search_syntax = Dusen::Description.read_syntax(&dsl) singleton_class.send(:define_method, :search) do |query_string| @search_syntax.search(self, query_string) end else @search_syntax 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dusen-0.2.1 | lib/dusen/active_record_ext.rb |
dusen-0.2.0 | lib/dusen/active_record_ext.rb |