Class: Djoini::IniLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/djoini/loaders/ini_loader.rb

Overview

Handles load of ini type files.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ IniLoader

Returns a new instance of IniLoader.



8
9
10
# File 'lib/djoini/loaders/ini_loader.rb', line 8

def initialize(path)
  self.path = path
end

Instance Attribute Details

#pathObject

Returns the value of attribute path.



6
7
8
# File 'lib/djoini/loaders/ini_loader.rb', line 6

def path
  @path
end

Instance Method Details

#load_files(array) ⇒ Object

Accepts array of [ { model: name, file: File },.. ]



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/djoini/loaders/ini_loader.rb', line 13

def load_files(array)
  array.each do |fixture|
    _model_table = Table.new(name: fixture[:model])

    _data = parse_ini(fixture[:file])

    _data.to_hash.each do |_, obj|
      _model_table.insert(obj)
    end
  end
end