BigW Consortium Gitlab

Commit 8c49eaa9 by Yorick Peterse

Cache Banzai class methods returning static data

These methods always return the same data for every class so there's no point in computing their values on every call.
parent 14114805
...@@ -11,15 +11,15 @@ module Banzai ...@@ -11,15 +11,15 @@ module Banzai
end end
def self.object_name def self.object_name
object_class.name.underscore @object_name ||= object_class.name.underscore
end end
def self.object_sym def self.object_sym
object_name.to_sym @object_sym ||= object_name.to_sym
end end
def self.data_reference def self.data_reference
"data-#{object_name.dasherize}" @data_reference ||= "data-#{object_name.dasherize}"
end end
# Public: Find references in text (like `!123` for merge requests) # Public: Find references in text (like `!123` for merge requests)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment