Sha256: 545848dc942ffc395b2fd606e85cd30f6b773c172faac39a402bda85e8f701e6

Contents?: true

Size: 573 Bytes

Versions: 1

Compression:

Stored size: 573 Bytes

Contents

# borrowed from http://titusd.co.uk/2010/01/31/regular-expressions-in-sqlite/

module SQLite3ARRegexp
  module Extension
    extend ActiveSupport::Concern

    included do
      alias_method :old_initialize, :initialize
      private :old_initialize

      def initialize(connection, logger, config)
        old_initialize(connection, logger, config)

        connection.create_function('regexp', 2) do |func, pattern, expression|
          func.result = expression.to_s.match(Regexp.new(pattern.to_s, Regexp::IGNORECASE)) ? 1 : 0
        end
      end 
    end 
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sqlite3_ar_regexp-2.0.0 lib/sqlite3_ar_regexp/extension.rb