Module: Referable::ClassMethods

Defined in:
app/models/concerns/referable.rb

Instance Method Summary collapse

Instance Method Details


52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'app/models/concerns/referable.rb', line 52

def link_reference_pattern(route, pattern)
  %r{
    (?<url>
      #{Regexp.escape(Gitlab.config.gitlab.url)}
      \/#{Project.reference_pattern}
      \/#{Regexp.escape(route)}
      \/#{pattern}
      (?<path>
        (\/[a-z0-9_=-]+)*
      )?
      (?<query>
        \?[a-z0-9_=-]+
        (&[a-z0-9_=-]+)*
      )?
      (?<anchor>\#[a-z0-9_-]+)?
    )
  }x
end

#reference_patternObject

Regexp pattern used to match references to this object

This must be overridden by the including class.

Returns a Regexp

Raises:

  • (NotImplementedError)

48
49
50
# File 'app/models/concerns/referable.rb', line 48

def reference_pattern
  raise NotImplementedError, "#{self} does not implement #{__method__}"
end

#reference_prefixObject

The character that prefixes the actual reference identifier

This should be overridden by the including class.

Examples:

Issue.reference_prefix        # => '#'
MergeRequest.reference_prefix # => '!'

Returns a String


39
40
41
# File 'app/models/concerns/referable.rb', line 39

def reference_prefix
  ''
end