Last active
May 26, 2023 21:37
-
-
Save jacksonpires/ab4c7078b64d5741734694aa945e4403 to your computer and use it in GitHub Desktop.
Create a custom node on Arel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
module ArelNodesTrgm | |
class Arel::Nodes::Trgm < Arel::Nodes::InfixOperation | |
def initialize(left, right) | |
super(:"%", left, right) | |
end | |
end | |
class Arel::Visitors::PostgreSQL < Arel::Visitors::ToSql | |
alias_method( | |
:visit_Arel_Nodes_Trgm, | |
:visit_Arel_Nodes_InfixOperation | |
) | |
end | |
end | |
# to use, just "include ArelNodesTrgm" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment