Class: LoaderDSL
- Inherits:
-
Object
- Object
- LoaderDSL
- Defined in:
- lib/dataload/loader.rb
Instance Method Summary collapse
- #column(name, type, &blk) ⇒ Object
- #database(ops) ⇒ Object
- #method_missing(sym, *args, &b) ⇒ Object
- #source(file) ⇒ Object
- #table(name) ⇒ Object
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &b) ⇒ Object
102 103 104 105 106 107 108 |
# File 'lib/dataload/loader.rb', line 102 def method_missing(sym,*args,&b) if [:string, :text, :integer, :float, :decimal, :datetime, :timestamp, :time, :date, :binary, :boolean].include?(sym) column(args.first,sym,&b) else super(sym,*args,&b) end end |
Instance Method Details
#column(name, type, &blk) ⇒ Object
98 99 100 101 |
# File 'lib/dataload/loader.rb', line 98 def column(name,type,&blk) blk ||= lambda { |x| x.send(name) } loader.columns << Column.new(:target_name => name, :blk => blk) end |
#database(ops) ⇒ Object
112 113 114 |
# File 'lib/dataload/loader.rb', line 112 def database(ops) loader.db_ops = ops end |
#source(file) ⇒ Object
109 110 111 |
# File 'lib/dataload/loader.rb', line 109 def source(file) loader.source_filename = file end |
#table(name) ⇒ Object
115 116 117 |
# File 'lib/dataload/loader.rb', line 115 def table(name) loader.table_name = name end |