Module: SafeParams::ConfigLoader
- Defined in:
- lib/safe_params/config_loader.rb
Class Method Summary collapse
Class Method Details
.load_for(model_name) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/safe_params/config_loader.rb', line 6 def self.load_for(model_name) file = Dir[Rails.root.join("config/safe_params.{yml,json}")].first return [] unless file && File.exist?(file) data = file.end_with?(".json") ? JSON.parse(File.read(file)) : YAML.load_file(file) data ||= {} data[model_name.to_s] || [] end |