method

register_handler

Importance_1
v4.2.7 - Show latest stable - 0 notes - Class: ActiveRecord::PredicateBuilder
register_handler(klass, handler) public

Define how a class is converted to Arel nodes when passed to where. The handler can be any object that responds to call, and will be used for any value that +===+ the class given. For example:

MyCustomDateRange = Struct.new(:start, :end)
handler = proc do |column, range|
  Arel::Nodes::Between.new(column,
    Arel::Nodes::And.new([range.start, range.end])
  )
end
ActiveRecord::PredicateBuilder.register_handler(MyCustomDateRange, handler)
Show source
Register or log in to add new notes.