Class: Skynet::ActiveRecordAsync

Inherits:
Object
  • Object
show all
Includes:
SkynetDebugger
Defined in:
lib/skynet/skynet_active_record_extensions.rb

Class Method Summary collapse

Methods included from SkynetDebugger

#args_pp, #debug, #debug_header, #error, #fatal, included, #info, #log, #printlog, #stderr, #stdout, #warn

Class Method Details

.map(datas) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/skynet/skynet_active_record_extensions.rb', line 42

def self.map(datas)
  datas.each do |data| 
    begin            
      model = data[:model_class].constantize.find(data[:model_id])
      if data[:opts]
        model.send(data[:method].to_sym, YAML.load(data[:opts]))
      else
        model.send(data[:method].to_sym)
      end
      model.save if data[:save]
    rescue Exception => e
      error "Error in #{self} #{e.inspect}"
    end
  end
  return
end