diff options
Diffstat (limited to 'lib/gitlab/serializer/ci/variables.rb')
-rw-r--r-- | lib/gitlab/serializer/ci/variables.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/gitlab/serializer/ci/variables.rb b/lib/gitlab/serializer/ci/variables.rb new file mode 100644 index 00000000000..c059c454eac --- /dev/null +++ b/lib/gitlab/serializer/ci/variables.rb @@ -0,0 +1,27 @@ +module Gitlab + module Serializer + 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]) + + object.map do |variable| + variable[:key] = variable[:key].to_s + variable + end + end + + def dump(object) + YAML.dump(object) + end + end + end + end +end |