Class: BeetleETL::DSL
- Inherits:
-
Object
- Object
- BeetleETL::DSL
- Defined in:
- lib/beetle_etl/dsl/dsl.rb
Instance Attribute Summary collapse
-
#column_names ⇒ Object
readonly
Returns the value of attribute column_names.
-
#query_strings ⇒ Object
readonly
Returns the value of attribute query_strings.
-
#relations ⇒ Object
readonly
Returns the value of attribute relations.
Instance Method Summary collapse
- #columns(*column_names) ⇒ Object
- #combined_key(*args) ⇒ Object
-
#initialize(table_name) ⇒ DSL
constructor
A new instance of DSL.
- #query(query) ⇒ Object
- #references(foreign_table, on: foreign_key) ⇒ Object
-
#stage_table(table_name = nil) ⇒ Object
query helper methods.
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_names ⇒ Object (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_strings ⇒ Object (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 |
#relations ⇒ Object (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 |