Class: Djoini::Files

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

Overview

Handles loading of ini and json fixtures

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fixtures_path = '') ⇒ Files

Returns a new instance of Files.



9
10
11
# File 'lib/djoini/files.rb', line 9

def initialize(fixtures_path = '')
  self.path = fixtures_path || Djoini.configuration.fixtures_folder
end

Instance Attribute Details

#pathObject

Returns the value of attribute path.



7
8
9
# File 'lib/djoini/files.rb', line 7

def path
  @path
end

Instance Method Details

#load_files(type = 'mixed') ⇒ Object



13
14
15
16
17
18
# File 'lib/djoini/files.rb', line 13

def load_files(type = 'mixed')
  puts "Loading #{type} files from #{path}"

  IniLoader.new(path).load_files(find_files('ini')) unless type == 'json'
  JsonLoader.new(path).load_files find_files('json') unless type == 'ini'
end