Class: Itiel::Extract::CustomSQL
- Inherits:
-
Object
- Object
- Itiel::Extract::CustomSQL
- Includes:
- DB::SQLConnectable, ChainedStep, Nameable
- Defined in:
- lib/itiel/extract/custom_sql.rb
Overview
Creates a stream from the specified SQL query. Connection must be defined on a file that’s on config/database.yml by default.
Usage:
@custom_sql = Itiel::Extract::CustomSQL.new
@custom_sql.connection = :test
@custom_sql.script = 'SELECT * FROM some_table'
You can set a different path for the config file at class level
Itiel::Extract::CustomSQL.connection_file_path = 'path_to_my_config/database.yml'
Direct Known Subclasses
Instance Attribute Summary collapse
-
#script ⇒ Object
Returns the value of attribute script.
Attributes included from Nameable
Attributes included from DB::SQLConnectable
#connection, #connection_file_path
Attributes included from ChainedStep
Instance Method Summary collapse
- #extract ⇒ Object
-
#initialize(*args) ⇒ CustomSQL
constructor
A new instance of CustomSQL.
Methods included from DB::SQLConnectable
Methods included from ChainedStep
Constructor Details
#initialize(*args) ⇒ CustomSQL
Returns a new instance of CustomSQL.
28 29 30 |
# File 'lib/itiel/extract/custom_sql.rb', line 28 def initialize(*args) self.script = args[0] end |
Instance Attribute Details
#script ⇒ Object
Returns the value of attribute script.
26 27 28 |
# File 'lib/itiel/extract/custom_sql.rb', line 26 def script @script end |
Instance Method Details
#extract ⇒ Object
32 33 34 35 |
# File 'lib/itiel/extract/custom_sql.rb', line 32 def extract db = self.class.sequel_connection(connection) db[script].all end |