diff options
Diffstat (limited to 'lib/gitlab/class_attributes.rb')
-rw-r--r-- | lib/gitlab/class_attributes.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/gitlab/class_attributes.rb b/lib/gitlab/class_attributes.rb index 6560c97b2e6..6eea7590cbd 100644 --- a/lib/gitlab/class_attributes.rb +++ b/lib/gitlab/class_attributes.rb @@ -14,6 +14,18 @@ module Gitlab class_attributes[name] || superclass_attributes(name) end + def set_class_attribute(name, value) + class_attributes[name] = value + + after_hooks.each(&:call) + + value + end + + def after_set_class_attribute(&block) + after_hooks << block + end + private def class_attributes @@ -25,6 +37,10 @@ module Gitlab superclass.get_class_attribute(name) end + + def after_hooks + @after_hooks ||= [] + end end end end |