From 76932b99d60b28f93c88c9a95873ba8524c9e370 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 23 Nov 2010 16:24:41 -0800 Subject: adding a "not" factory method for creating Not nodes --- lib/arel/nodes/node.rb | 7 +++++++ lib/arel/nodes/not.rb | 11 +++++++++++ 2 files changed, 18 insertions(+) create mode 100644 lib/arel/nodes/not.rb (limited to 'lib/arel/nodes') diff --git a/lib/arel/nodes/node.rb b/lib/arel/nodes/node.rb index 43bad19488..841b954db9 100644 --- a/lib/arel/nodes/node.rb +++ b/lib/arel/nodes/node.rb @@ -3,6 +3,13 @@ module Arel ### # Abstract base class for all AST nodes class Node + ### + # Factory method to create a Nodes::Not node that has the recipient of + # the caller as a child. + def not + Nodes::Not.new self + end + ### # Factory method to create a Nodes::Grouping node that has an Nodes::Or # node as a child. diff --git a/lib/arel/nodes/not.rb b/lib/arel/nodes/not.rb new file mode 100644 index 0000000000..d463ae9d08 --- /dev/null +++ b/lib/arel/nodes/not.rb @@ -0,0 +1,11 @@ +module Arel + module Nodes + class Not < Arel::Nodes::Node + attr_reader :expr + + def initialize expr + @expr = expr + end + end + end +end -- cgit v1.2.3