Class: DataRegister

Inherits:
Object
  • Object
show all
Defined in:
lib/pokotarou/data_register.rb

Class Method Summary collapse

Class Method Details

.regist(data) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/pokotarou/data_register.rb', line 6

def regist data
  # init maked to accumulate maded data
  maked = Hash.new
  # init model_data to cache data of model
  model_cache = Hash.new
  ActiveRecord::Base.transaction do
    begin
      data.each do |sym_block, model_data|
        next if is_dush?(sym_block.to_s)
        regist_models(sym_block, model_data, maked, model_cache)
      end
    rescue => e
      raise StandardError.new("#{e.message}")
    end
  end

  ReturnExpressionParser.parse(data[:"return'"], maked) 
end