From 0c8723af70b8518c1a9ae43e650afb433e078470 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Mon, 27 Jun 2011 09:11:47 -0700 Subject: visitors can define their own cache strategy for dispatch. fixes #57 --- test/visitors/test_to_sql.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test') diff --git a/test/visitors/test_to_sql.rb b/test/visitors/test_to_sql.rb index d046e543e1..b52722ddd6 100644 --- a/test/visitors/test_to_sql.rb +++ b/test/visitors/test_to_sql.rb @@ -13,6 +13,22 @@ module Arel @attr = @table[:id] end + it 'can define a dispatch method' do + visited = false + viz = Class.new(Arel::Visitors::Visitor) { + define_method(:hello) do |node| + visited = true + end + + def dispatch + { Arel::Table => 'hello' } + end + }.new + + viz.accept(@table) + assert visited, 'hello method was called' + end + it "should be thread safe around usage of last_column" do visit_integer_column = Thread.new do Thread.stop -- cgit v1.2.3