Module: Interpol::ConfigurationRuby18Extensions
- Included in:
- Configuration
- Defined in:
- lib/interpol/configuration_ruby_18_extensions.rb
Instance Method Summary collapse
-
#bad_deserialized_yaml(yaml) ⇒ Object
returns nil if the YAML has been only partially deserialized by Syck and there are YAML::Syck objects.
- #deserialized_hash_from(file) ⇒ Object
Instance Method Details
#bad_deserialized_yaml(yaml) ⇒ Object
returns nil if the YAML has been only partially deserialized by Syck and there are YAML::Syck objects.
17 18 19 20 21 22 23 24 25 |
# File 'lib/interpol/configuration_ruby_18_extensions.rb', line 17 def bad_deserialized_yaml(yaml) if [Hash, Array].include? yaml.class yaml.map { |elem| bad_deserialized_yaml(elem) }.compact.first elsif yaml.class.name =~ /YAML::Syck::/ yaml.class.name # Bad! else nil end end |
#deserialized_hash_from(file) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/interpol/configuration_ruby_18_extensions.rb', line 3 def deserialized_hash_from(file) YAML.load(yaml_content_for file).tap do |yaml| if bad_class = bad_deserialized_yaml(yaml) raise ConfigurationError.new \ "Received an error while loading YAML from #{file}: \"" + "Got object of type: #{bad_class}\"\n If you are using YAML merge keys " + "to declare shared types, you must configure endpoint_definition_merge_key_files " + "before endpoint_definition_files." end end end |