Sha256: d449764ebf14e92849802975ccd67ffd8d02e191f852414eaabc4fc08e506a0b
Contents?: true
Size: 1.15 KB
Versions: 14
Compression:
Stored size: 1.15 KB
Contents
require 'arel/visitors/postgresql' # We override some fun stuff in the PostgreSQL visitor class inside of Arel. # This is the _most_ direct approach to tweaking the SQL to INSERT, SELECT, # and UPDATE values as encrypted. Unfortunately, the visitor API doesn't # give us access to managers as well as nodes, so we have use the public # Arel API via the connection adapter's to_sql method. Then we tweak the # more specific bits here! Arel::Visitors::PostgreSQL.class_eval do unless instance_methods.include?(:visit_Arel_Nodes_Assignment_without_pgcrypto) || instance_methods.include?('visit_Arel_Nodes_Assignment_without_pgcrypto') alias :visit_Arel_Nodes_Assignment_without_pgcrypto :visit_Arel_Nodes_Assignment end def visit_Arel_Nodes_Assignment(assignment) # Hijack the normally inoccuous assignment that happens, seeing as how # Arel normally forwards this shit to someone else and I hate it. if assignment.left.relation.name == PGCrypto::Column.table_name && assignment.left.name == 'value' "#{visit(assignment.left)} = #{visit(assignment.right)}" else visit_Arel_Nodes_Assignment_without_pgcrypto(assignment) end end end
Version data entries
14 entries across 14 versions & 1 rubygems