Class: Squeel::Nodes::Node
- Inherits:
-
Object
- Object
- Squeel::Nodes::Node
- Includes:
- Polyamorous::TreeNode
- Defined in:
- lib/squeel/nodes/node.rb
Direct Known Subclasses
Binary, Function, Join, KeyPath, Literal, Nary, Order, Predicate, Sifter, Stub, SubqueryJoin, Unary
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#grep(object, &block) ⇒ Object
We don’t want the full Enumerable method list, because it will mess with stuff like KeyPath.
Instance Method Details
#each(&block) ⇒ Object
8 9 10 11 12 |
# File 'lib/squeel/nodes/node.rb', line 8 def each(&block) return enum_for(:each) unless block_given? Visitors::EnumerationVisitor.new(block).accept(self) end |
#grep(object, &block) ⇒ Object
We don’t want the full Enumerable method list, because it will mess with stuff like KeyPath
16 17 18 19 20 21 22 23 24 |
# File 'lib/squeel/nodes/node.rb', line 16 def grep(object, &block) if block_given? each { |value| yield value if object === value } else [].tap do |results| each { |value| results << value if object === value } end end end |