Module: CemAcpt::ConfigUtils
- Extended by:
- Logging
- Defined in:
- lib/cem_acpt/shared_objects.rb
Overview
Holds module methods for writing various config objects to files.
Constant Summary
Constants included from Logging
Class Method Summary collapse
Methods included from Logging
current_log_config, current_log_config, current_log_format, current_log_format, current_log_level, current_log_level, included, logger, logger, new_log_config, new_log_config, new_log_formatter, new_log_formatter, new_log_level, new_log_level, new_logger, new_logger
Class Method Details
.object_to_file(obj, file_path) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/cem_acpt/shared_objects.rb', line 22 def self.object_to_file(obj, file_path) case File.extname(file_path) when '.json' raise "Object #{obj} is not serializable to JSON" unless obj.respond_to?(:to_json) logger.debug("Writing object to #{file_path}") File.write(file_path, obj.to_json) when '.yaml', '.yml' raise "Object #{obj} is not serializable to YAML" unless obj.respond_to?(:to_yaml) logger.debug("Writing object to #{file_path}") File.write(file_path, obj.to_yaml) else raise "File extension #{File.extname(file_path)} is not supported" end end |