Class: BeetleETL::DSL

Inherits:
Object
  • Object
show all
Defined in:
lib/beetle_etl/dsl/dsl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(table_name) ⇒ DSL

Returns a new instance of DSL.



6
7
8
9
10
11
# File 'lib/beetle_etl/dsl/dsl.rb', line 6

def initialize(table_name)
  @table_name = table_name
  @column_names = []
  @relations = {}
  @query_strings = []
end

Instance Attribute Details

#column_namesObject (readonly)

Returns the value of attribute column_names.



4
5
6
# File 'lib/beetle_etl/dsl/dsl.rb', line 4

def column_names
  @column_names
end

#query_stringsObject (readonly)

Returns the value of attribute query_strings.



4
5
6
# File 'lib/beetle_etl/dsl/dsl.rb', line 4

def query_strings
  @query_strings
end

#relationsObject (readonly)

Returns the value of attribute relations.



4
5
6
# File 'lib/beetle_etl/dsl/dsl.rb', line 4

def relations
  @relations
end

Instance Method Details

#columns(*column_names) ⇒ Object



13
14
15
# File 'lib/beetle_etl/dsl/dsl.rb', line 13

def columns(*column_names)
  @column_names = column_names
end

#combined_key(*args) ⇒ Object



31
32
33
# File 'lib/beetle_etl/dsl/dsl.rb', line 31

def combined_key(*args)
  %Q('[' || #{args.join(%q[ || ',' || ])} || ']')
end

#query(query) ⇒ Object



21
22
23
# File 'lib/beetle_etl/dsl/dsl.rb', line 21

def query(query)
  @query_strings << query
end

#references(foreign_table, on: foreign_key) ⇒ Object



17
18
19
# File 'lib/beetle_etl/dsl/dsl.rb', line 17

def references(foreign_table, on: foreign_key)
  @relations[on] = foreign_table
end

#stage_table(table_name = nil) ⇒ Object

query helper methods



27
28
29
# File 'lib/beetle_etl/dsl/dsl.rb', line 27

def stage_table(table_name = nil)
  BeetleETL::Naming.stage_table_name_sql(table_name || @table_name)
end