Sha256: 33ccccf0e2ee1ad9ad1d4234ec6b482eb0345967540dccf65185fd684fd66431

Contents?: true

Size: 563 Bytes

Versions: 1

Compression:

Stored size: 563 Bytes

Contents

# frozen_string_literal: true

# 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(*args)
        old_initialize(*args)

        raw_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-3.0.0 lib/sqlite3_ar_regexp/extension.rb