Class: Bmg::Sql::Processor::Extend

Inherits:
Bmg::Sql::Processor show all
Defined in:
lib/bmg/sql/processor/extend.rb

Constant Summary

Constants inherited from Bmg::Sql::Processor

UnexpectedError

Instance Attribute Summary collapse

Attributes inherited from Bmg::Sql::Processor

#builder

Instance Method Summary collapse

Methods inherited from Bmg::Sql::Processor

#on_select_exp, #on_with_exp

Constructor Details

#initialize(extension, builder) ⇒ Extend

Returns a new instance of Extend.



6
7
8
9
# File 'lib/bmg/sql/processor/extend.rb', line 6

def initialize(extension, builder)
  super(builder)
  @extension = extension
end

Instance Attribute Details

#extensionObject (readonly)

Returns the value of attribute extension.



10
11
12
# File 'lib/bmg/sql/processor/extend.rb', line 10

def extension
  @extension
end

Instance Method Details

#on_select_list(sexpr) ⇒ Object



23
24
25
26
27
28
# File 'lib/bmg/sql/processor/extend.rb', line 23

def on_select_list(sexpr)
  sexpr + extension.each_pair.map{|(k,v)|
    desaliased = sexpr.desaliaser[v]
    [:select_item, desaliased, [:column_name, k] ]
  }
end

#on_select_star(sexpr) ⇒ Object

Raises:

  • (NotImplementedError)


19
20
21
# File 'lib/bmg/sql/processor/extend.rb', line 19

def on_select_star(sexpr)
  raise NotImplementedError, "Extend on * is not supported"
end

#on_set_operator(sexpr) ⇒ Object Also known as: on_union, on_except, on_intersect



12
13
14
# File 'lib/bmg/sql/processor/extend.rb', line 12

def on_set_operator(sexpr)
  apply(builder.from_self(sexpr))
end