Module: CustomFormGenerator::Helpers::JsonLoader

Included in:
Generator
Defined in:
lib/custom_form_generator/helpers/json_loader.rb

Overview

JsonLoader module provides JSON file loading functionality with safety checks along with error handling for the CustomFormGenerator gem

Instance Method Summary collapse

Instance Method Details

#load_json(file_path) ⇒ Object



11
12
13
14
15
# File 'lib/custom_form_generator/helpers/json_loader.rb', line 11

def load_json(file_path)
  raise CustomFormGenerator::Error, "JSON file not found: #{file_path}" unless File.exist?(file_path)

  JSON.parse(File.read(file_path))
end