Module: Rigrate::Migration
- Included in:
- Parser
- Defined in:
- lib/rigrate/migration.rb
Instance Method Summary collapse
- #data_source(name, conn_str) ⇒ Object (also: #ds)
- #join(rs_first_str, rs_second_str, condition = nil) ⇒ Object
-
#migrate(rs_first_str, rs_second_str, condition = nil, mode = nil) ⇒ Object
migration mode.
- #minus(rs_first_str, rs_second_str) ⇒ Object
- #self_eval(rb_str) ⇒ Object
- #union(rs_first_str, rs_second_str) ⇒ Object
Instance Method Details
#data_source(name, conn_str) ⇒ Object Also known as: ds
79 80 81 82 83 84 85 86 |
# File 'lib/rigrate/migration.rb', line 79 def data_source(name, conn_str) name = name.to_s ds = DataSource.new(conn_str) variable_name = "@#{name}".to_sym unless name.start_with? "@" instance_variable_set variable_name, ds instance_eval("def #{name}=(x); #{variable_name}=x; end;\ def #{name}; #{variable_name}; end") end |
#join(rs_first_str, rs_second_str, condition = nil) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/rigrate/migration.rb', line 37 def join(rs_first_str, rs_second_str, condition = nil) if String === rs_first_str rs_first = instance_eval rs_first_str else rs_first = rs_first_str end condition = eval("{#{condition}}") unless condition.nil? rs_second = instance_eval rs_second_str if ResultSet === rs_first && ResultSet === rs_second Rigrate.logger.info("start join two ResultSet rs [#{rs_first.size}] <---> rs [#{rs_second.size}]") return rs_first.join(rs_second, condition) else raise Exception.new('rs_first or rs_second is not a resultset') end end |
#migrate(rs_first_str, rs_second_str, condition = nil, mode = nil) ⇒ Object
migration mode
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/rigrate/migration.rb', line 55 def migrate(rs_first_str, rs_second_str, condition = nil, mode = nil) if String === rs_first_str rs_source = instance_eval rs_first_str else rs_source = rs_first_str end rs_target = instance_eval rs_second_str default_opts = { :mode => Rigrate.config[:mode] } if mode default_opts[:mode] = instance_eval("#{mode}") end if ResultSet === rs_source && ResultSet === rs_target return rs_target.migrate_from(rs_source, condition, default_opts) else raise Exception.new('rs_target or rs_source is not a resultset.') end end |
#minus(rs_first_str, rs_second_str) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rigrate/migration.rb', line 21 def minus(rs_first_str, rs_second_str) if String === rs_first_str rs_first = instance_eval rs_first_str else rs_first = rs_first_str end rs_second = instance_eval rs_second_str if ResultSet === rs_first && ResultSet === rs_second Rigrate.logger.info("start minus two ResultSet rs [#{rs_first.size}] <---> rs [#{rs_second.size}]") return rs_first.minus rs_second else raise Exception.new('rs_first or rs_second is not a resultset') end end |
#self_eval(rb_str) ⇒ Object
75 76 77 |
# File 'lib/rigrate/migration.rb', line 75 def self_eval(rb_str) instance_eval(rb_str) end |
#union(rs_first_str, rs_second_str) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/rigrate/migration.rb', line 5 def union(rs_first_str, rs_second_str) if String === rs_first_str rs_first = instance_eval rs_first_str else rs_first = rs_first_str end rs_second = instance_eval rs_second_str if ResultSet === rs_first && ResultSet === rs_second Rigrate.logger.info("start union two ResultSet rs [#{rs_first.size}] <---> rs [#{rs_second.size}]") return rs_first.union rs_second else raise Exception.new('rs_first or rs_second is not a resultset') end end |