Sha256: 30bd329b7742a15ff9aec143d5f17d6c428fd58e71dfbaae495f04c7b3d04a69

Contents?: true

Size: 780 Bytes

Versions: 4

Compression:

Stored size: 780 Bytes

Contents

module MistralClient
  module Mixins
    module Definable
      # rubocop:disable Metrics/MethodLength
      def parse_definition(definition)
        if definition.is_a?(Hash) || definition.is_a?(Array)
          return YAML.dump(definition)
        end
        definition = File.read(definition) if File.exist?(definition)
        # Called outside the if/else to validate the YAML.
        parsed = YAML.safe_load(definition, [], [], true)
        if defined? massage_definition
          massage_definition(parsed)
        else
          definition
        end
      rescue Psych::SyntaxError
        raise ConfigurationError,
              'Only filenames or raw or parsed strings of YAML are supported.'
      end
      # rubocop:enable Metrics/MethodLength
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mistral_client-1.2.1 lib/mistral_client/mixins/definable.rb
mistral_client-1.2.0 lib/mistral_client/mixins/definable.rb
mistral_client-1.1.0 lib/mistral_client/mixins/definable.rb
mistral_client-1.0.0 lib/mistral_client/mixins/definable.rb