Method: UltraSettings::Configuration#__to_hash__
- Defined in:
- lib/ultra_settings/configuration.rb
#__to_hash__ ⇒ Hash
Output the current state of the configuration as a hash. If the field is marked as a secret, then the value will be a secure hash of the value instead of the value itself.
The intent of this method is to provide a serializable value that captures the current state of the configuration without exposing any secrets. You could, for instance, use the output to compare the configuration of you application between two different environments.
557 558 559 560 561 562 563 564 565 566 567 |
# File 'lib/ultra_settings/configuration.rb', line 557 def __to_hash__ payload = {} self.class.fields.each do |field| value = self[field.name] if field.secret? && !value.nil? value = "securehash:#{Digest::MD5.hexdigest(Digest::SHA256.hexdigest(value.to_s))}" end payload[field.name] = value end payload end |