summaryrefslogtreecommitdiff
path: root/lib/gitlab/serializer
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-02-06 14:34:10 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-02-06 14:34:10 +0100
commit10c1a4d8e4828992afa56bfca6b61eeb328d851e (patch)
tree038b711172ac4ed47bb24c421611b166440b5e2f /lib/gitlab/serializer
parent50aec8dd0df863c6f129edb505218e744c479a4b (diff)
downloadgitlab-ce-10c1a4d8e4828992afa56bfca6b61eeb328d851e.tar.gz
Rename `Gitlab::Serialize` module to reuse it later
Diffstat (limited to 'lib/gitlab/serializer')
-rw-r--r--lib/gitlab/serializer/ci/variables.rb27
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