Class: Qonfig::Uploaders::YAML Private
- Defined in:
- lib/qonfig/uploaders/yaml.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Classes: YAMLRepresenter
Constant Summary collapse
- DEFAULT_OPTIONS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{ indentation: 2, line_width: -1, canonical: false, header: false, symbolize_keys: false }.freeze
- KEY_SYMBOLIZER =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
-> (value) { value.to_sym }.freeze
Constants inherited from File
File::EMPTY_SETTINGS_REPRESENTATION, File::FILE_OPENING_MODE
Class Method Summary collapse
- .hash_representation_options(options, &value_processor) ⇒ Hash private
- .represent_settings(settings, options, &value_processor) ⇒ String private
- .to_yaml_string(settings_hash, yaml_options) ⇒ String private
Methods inherited from File
Methods inherited from Base
Class Method Details
.hash_representation_options(options, &value_processor) ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/qonfig/uploaders/yaml.rb', line 60 def (, &value_processor) {}.tap do |representation_opts| # NOTE: this case/when with the same logic is only used for better code readbility # rubocop:disable Lint/DuplicateBranch case # NOTE: options has :symbolize_keys key when .key?(:symbolize_keys) && !![:symbolize_keys] representation_opts[:transform_key] = KEY_SYMBOLIZER # NOTE: options does not have :symbolize_keys key when !.key?(:symbolize_keys) && DEFAULT_OPTIONS[:symbolize_keys] # :nocov: representation_opts[:transform_key] = KEY_SYMBOLIZER # :nocov: end # rubocop:enable Lint/DuplicateBranch # NOTE: provide value transformer if block_given? representation_opts[:transform_value] = value_processor end end end |
.represent_settings(settings, options, &value_processor) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
48 49 50 51 52 |
# File 'lib/qonfig/uploaders/yaml.rb', line 48 def represent_settings(settings, , &value_processor) settings_hash_opts = (, &value_processor) settings_hash = settings.__to_hash__(**settings_hash_opts) to_yaml_string(settings_hash, ) end |
.to_yaml_string(settings_hash, yaml_options) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
89 90 91 92 93 |
# File 'lib/qonfig/uploaders/yaml.rb', line 89 def to_yaml_string(settings_hash, ) representer = YAMLRepresenter.create() representer << settings_hash representer.tree.yaml(nil, ) end |