Class: Piglet::Relation::Order

Inherits:
Object
  • Object
show all
Includes:
Relation
Defined in:
lib/piglet/relation/order.rb

Overview

:nodoc:

Instance Attribute Summary

Attributes included from Relation

#sources

Instance Method Summary collapse

Methods included from Relation

#[], #alias, #cogroup, #cross, #distinct, #eql?, #field, #filter, #foreach, #group, #hash, #join, #limit, #method_missing, #nested_foreach, #next_field_alias, #order, #sample, #schema, #split, #stream, #union

Constructor Details

#initialize(relation, interpreter, fields, options) ⇒ Order

Returns a new instance of Order.



8
9
10
11
12
13
# File 'lib/piglet/relation/order.rb', line 8

def initialize(relation, interpreter, fields, options)
  options ||= {}
  @interpreter = interpreter
  @sources, @parallel = [relation], options[:parallel]
  @fields = fields.is_a?(Enumerable) ? fields : [fields]
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Piglet::Relation::Relation

Instance Method Details

#to_sObject



15
16
17
18
# File 'lib/piglet/relation/order.rb', line 15

def to_s
  target = @sources.first.respond_to?(:field_alias) ? @sources.first.field_alias : @sources.first.alias
  "ORDER #{target} BY #{field_strings}"
end