Class ApplicationTableService
In: lib/design_api.rb
Parent: DesignSubService

Design Web サービスでテーブル設定を扱う API を実装する。

Methods

export   import  

Public Instance methods

book として与えられたデータでテーブルを置き換える。

[Source]

      # File lib/design_api.rb, line 1286
1286:   def export(book)
1287:     # drop current tables
1288:     ApplicationTable.destroy_all
1289:     # generate new tables
1290:     book.main_sheet.tables.each do |t|
1291:       table = ApplicationTable.create!(:name => t.name)
1292:       t.columns.each do |c|
1293:         column_class = c.type.constantize
1294:         column = column_class.new(:table_type => "ApplicationTable",
1295:                                   :table_id => table.id)
1296:         [:name, :length].each {|k| column.__send__("#{k}=", c.__send__(k))}
1297:         column.save!
1298:       end
1299:       table.create_table
1300:     end
1301:     return ApplicationTable.to_book.succeed
1302:   end

application_tables と table_columns の内容をクライアントへ送る。

[Source]

      # File lib/design_api.rb, line 1281
1281:   def import(book)
1282:     return ApplicationTable.to_book.succeed
1283:   end

[Validate]