diff options
Diffstat (limited to 'lib/gitlab/audit/type')
-rw-r--r-- | lib/gitlab/audit/type/definition.rb | 13 | ||||
-rw-r--r-- | lib/gitlab/audit/type/shared.rb | 25 |
2 files changed, 26 insertions, 12 deletions
diff --git a/lib/gitlab/audit/type/definition.rb b/lib/gitlab/audit/type/definition.rb index af5dc9f4b44..f64f66f4ca4 100644 --- a/lib/gitlab/audit/type/definition.rb +++ b/lib/gitlab/audit/type/definition.rb @@ -5,6 +5,7 @@ module Gitlab module Type class Definition include ActiveModel::Validations + include ::Gitlab::Audit::Type::Shared attr_reader :path attr_reader :attributes @@ -17,18 +18,6 @@ module Gitlab AUDIT_EVENT_TYPE_SCHEMA_PATH = Rails.root.join('config', 'audit_events', 'types', 'type_schema.json') AUDIT_EVENT_TYPE_SCHEMA = JSONSchemer.schema(AUDIT_EVENT_TYPE_SCHEMA_PATH) - # The PARAMS in config/audit_events/types/type_schema.json - PARAMS = %i[ - name - description - introduced_by_issue - introduced_by_mr - group - milestone - saved_to_database - streamed - ].freeze - PARAMS.each do |param| define_method(param) do attributes[param] diff --git a/lib/gitlab/audit/type/shared.rb b/lib/gitlab/audit/type/shared.rb new file mode 100644 index 00000000000..999b7de13e2 --- /dev/null +++ b/lib/gitlab/audit/type/shared.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +# This file can contain only simple constructs as it is shared between: +# 1. `Pure Ruby`: `bin/audit-event-type` +# 2. `GitLab Rails`: `lib/gitlab/audit/type/definition.rb` + +module Gitlab + module Audit + module Type + module Shared + # The PARAMS in config/audit_events/types/type_schema.json + PARAMS = %i[ + name + description + introduced_by_issue + introduced_by_mr + group + milestone + saved_to_database + streamed + ].freeze + end + end + end +end |