Class: Gitlab::GrapeOpenapi::Models::Tag
- Inherits:
-
Object
- Object
- Gitlab::GrapeOpenapi::Models::Tag
- Defined in:
- lib/gitlab/grape_openapi/models/tag.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize(name) ⇒ Tag
constructor
A new instance of Tag.
- #to_h ⇒ Object
Constructor Details
#initialize(name) ⇒ Tag
Returns a new instance of Tag.
25 26 27 |
# File 'lib/gitlab/grape_openapi/models/tag.rb', line 25 def initialize(name) @name = Gitlab::GrapeOpenapi::Models::Tag.normalize_tag_name(name) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
23 24 25 |
# File 'lib/gitlab/grape_openapi/models/tag.rb', line 23 def name @name end |
Class Method Details
.apply_overrides(text) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/gitlab/grape_openapi/models/tag.rb', line 12 def self.apply_overrides(text) overrides = Gitlab::GrapeOpenapi.configuration.tag_overrides return text if overrides.nil? || overrides.empty? pattern = Regexp.union(overrides.keys.map { |key| /\b#{Regexp.escape(key)}\b/i }) text.gsub(pattern) do |match| overrides[match] || overrides[match.downcase] || overrides[match.capitalize] || match end end |
.normalize_tag_name(tag_name) ⇒ Object
7 8 9 10 |
# File 'lib/gitlab/grape_openapi/models/tag.rb', line 7 def self.normalize_tag_name(tag_name) name = tag_name.split('_').join(' ').capitalize apply_overrides(name) end |
Instance Method Details
#description ⇒ Object
36 37 38 39 40 |
# File 'lib/gitlab/grape_openapi/models/tag.rb', line 36 def description desc_name = name.downcase desc_adjusted = self.class.apply_overrides(desc_name) "Operations related to #{desc_adjusted}." end |
#to_h ⇒ Object
29 30 31 32 33 34 |
# File 'lib/gitlab/grape_openapi/models/tag.rb', line 29 def to_h { name: name, description: description }.compact end |