Class: Piglet::Relation::Foreach
- Inherits:
-
Object
- Object
- Piglet::Relation::Foreach
- Includes:
- Relation
- Defined in:
- lib/piglet/relation/foreach.rb
Overview
:nodoc:
Instance Attribute Summary
Attributes included from Relation
Instance Method Summary collapse
-
#initialize(relation, field_expressions) ⇒ Foreach
constructor
A new instance of Foreach.
- #schema ⇒ Object
- #to_s ⇒ Object
Methods included from Relation
#[], #alias, #cogroup, #cross, #distinct, #eql?, #field, #filter, #foreach, #group, #hash, #join, #limit, #method_missing, #order, #sample, #split, #stream, #union
Constructor Details
#initialize(relation, field_expressions) ⇒ Foreach
Returns a new instance of Foreach.
8 9 10 |
# File 'lib/piglet/relation/foreach.rb', line 8 def initialize(relation, field_expressions) @sources, @field_expressions = [relation], [field_expressions].flatten end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Piglet::Relation::Relation
Instance Method Details
#schema ⇒ Object
12 13 14 15 |
# File 'lib/piglet/relation/foreach.rb', line 12 def schema description = @field_expressions.map { |expr| [expr.name, expr.type] } Piglet::Schema::Tuple.parse(description) end |
#to_s ⇒ Object
17 18 19 |
# File 'lib/piglet/relation/foreach.rb', line 17 def to_s "FOREACH #{@sources.first.alias} GENERATE #{field_expressions_string}" end |