diff options
Diffstat (limited to 'lib/arel/relations/selection.rb')
-rw-r--r-- | lib/arel/relations/selection.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/arel/relations/selection.rb b/lib/arel/relations/selection.rb new file mode 100644 index 0000000000..38a40e1b76 --- /dev/null +++ b/lib/arel/relations/selection.rb @@ -0,0 +1,21 @@ +module Arel + class Selection < Compound + attr_reader :predicate + + def initialize(relation, *predicates) + predicate = predicates.shift + @relation = predicates.empty?? relation : Selection.new(relation, *predicates) + @predicate = predicate.bind(@relation) + end + + def ==(other) + self.class == other.class and + relation == other.relation and + predicate == other.predicate + end + + def selects + relation.selects + [predicate] + end + end +end
\ No newline at end of file |