class Djoini::JsonLoader
Handles load of ini type files.
Attributes
path[RW]
Public Class Methods
new(path)
click to toggle source
# File lib/djoini/loaders/json_loader.rb, line 8 def initialize(path) self.path = path end
Public Instance Methods
load_files(array)
click to toggle source
Accepts array of [ { model: name, file: File },.. ]
# File lib/djoini/loaders/json_loader.rb, line 13 def load_files(array) array.each do |fixture| _model_table = Table.new(name: fixture[:model]) _data = parse_json(fixture[:file]) _data.each do |obj| _model_table.insert(obj) end end end
Private Instance Methods
parse_json(file)
click to toggle source
# File lib/djoini/loaders/json_loader.rb, line 29 def parse_json(file) MultiJson.load(File.read(File.join(path, file))) end