Class: DataImport::Dsl
- Inherits:
-
Object
- Object
- DataImport::Dsl
- Defined in:
- lib/data-import/dsl.rb,
lib/data-import/dsl/import.rb,
lib/data-import/dsl/import/from.rb
Defined Under Namespace
Classes: Import
Instance Attribute Summary collapse
-
#source_database ⇒ Object
readonly
Returns the value of attribute source_database.
-
#target_database ⇒ Object
readonly
Returns the value of attribute target_database.
Class Method Summary collapse
Instance Method Summary collapse
- #before_filter(&block) ⇒ Object
- #import(name, &block) ⇒ Object
-
#initialize(plan) ⇒ Dsl
constructor
A new instance of Dsl.
- #source(*args) ⇒ Object
- #target(*args) ⇒ Object
Constructor Details
#initialize(plan) ⇒ Dsl
Returns a new instance of Dsl.
31 32 33 |
# File 'lib/data-import/dsl.rb', line 31 def initialize(plan) @plan = plan end |
Instance Attribute Details
#source_database ⇒ Object (readonly)
Returns the value of attribute source_database.
29 30 31 |
# File 'lib/data-import/dsl.rb', line 29 def source_database @source_database end |
#target_database ⇒ Object (readonly)
Returns the value of attribute target_database.
29 30 31 |
# File 'lib/data-import/dsl.rb', line 29 def target_database @target_database end |
Class Method Details
.define(&block) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/data-import/dsl.rb', line 15 def define(&block) plan = DataImport::ExecutionPlan.new context = new(plan) context.instance_eval &block plan end |
.evaluate_import_config(file) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/data-import/dsl.rb', line 8 def evaluate_import_config(file) plan = DataImport::ExecutionPlan.new context = new(plan) context.instance_eval read_import_config(file), file plan end |
.read_import_config(file) ⇒ Object
22 23 24 |
# File 'lib/data-import/dsl.rb', line 22 def read_import_config(file) File.read(file) end |
Instance Method Details
#before_filter(&block) ⇒ Object
50 51 52 |
# File 'lib/data-import/dsl.rb', line 50 def before_filter(&block) @plan.before_filter = block end |
#import(name, &block) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/data-import/dsl.rb', line 43 def import(name, &block) definition = DataImport::Definition::Simple.new(name, source_database, target_database) @plan.add_definition(definition) Import.new(definition).instance_eval &block if block_given? end |
#source(*args) ⇒ Object
35 36 37 |
# File 'lib/data-import/dsl.rb', line 35 def source(*args) @source_database = DataImport::Database.connect(*args) end |
#target(*args) ⇒ Object
39 40 41 |
# File 'lib/data-import/dsl.rb', line 39 def target(*args) @target_database = DataImport::Database.connect(*args) end |