BigW Consortium Gitlab

variables.rb 649 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
module Gitlab
  module Serialize
    module Ci
      # This serializer could make sure our YAML variables' keys and values
      # are always strings. This is more for legacy build data because
      # from now on we convert them into strings before saving to database.
      module Variables
        extend self

        def load(string)
          return unless string

          object = YAML.safe_load(string, [Symbol])

15 16 17 18
          object.map do |variable|
            variable[:key] = variable[:key].to_s
            variable
          end
19 20 21 22 23 24 25 26 27
        end

        def dump(object)
          YAML.dump(object)
        end
      end
    end
  end
end