Sha256: 0d7d0132d8d6e6fb0eba6463f5763d6a3ff26c97f31b977c823f5a3da839a246

Contents?: true

Size: 781 Bytes

Versions: 1

Compression:

Stored size: 781 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

1 entries across 1 versions & 1 rubygems

Version Path
mistral_client-1.3.0 lib/mistral_client/mixins/definable.rb