Module: PicoPhone::Rails::PhoneSearchIndex

Extended by:
ActiveSupport::Concern
Defined in:
lib/pico_phone/rails/phone_search_index.rb

Overview

Included into ActiveRecord::Base by the railtie. Adds a maintain_phone_search_index class macro for a table that's already one-row-per-phone-number (unlike Extraction, which is for a free-text column that might mention a number anywhere in it). Keeps configurable sibling columns in sync via before_save -- no child table, no polymorphic association.

Examples:

class PhoneNumber < ApplicationRecord
  maintain_phone_search_index :number,
    region: "US",
    columns: { e164: :e164, national_digits: :national_digits, reversed_digits: :reverse_index }
end

PhoneNumber.phone_number_index_matching("(510) 274-5656")
PhoneNumber.phone_number_index_starting_with("(510)")
PhoneNumber.phone_number_index_ending_with("5656")