Class: Djoini::JsonLoader
- Inherits:
-
Object
- Object
- Djoini::JsonLoader
- Defined in:
- lib/djoini/loaders/json_loader.rb
Overview
Handles load of ini type files.
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(path) ⇒ JsonLoader
constructor
A new instance of JsonLoader.
-
#load_files(array) ⇒ Object
Accepts array of [ { model: name, file: File },.. ].
Constructor Details
#initialize(path) ⇒ JsonLoader
Returns a new instance of JsonLoader.
8 9 10 |
# File 'lib/djoini/loaders/json_loader.rb', line 8 def initialize(path) self.path = path end |
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
6 7 8 |
# File 'lib/djoini/loaders/json_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/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 |