Module: Gitlab::View::Presenter::Base

Extended by:
ActiveSupport::Concern
Includes:
Allowable, Routing
Included in:
Delegated, Simple
Defined in:
lib/gitlab/view/presenter/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Routing

add_helpers, includes_helpers, redirect_legacy_paths, url_helpers

Instance Attribute Details

#subjectObject (readonly)

Returns the value of attribute subject


14
15
16
# File 'lib/gitlab/view/presenter/base.rb', line 14

def subject
  @subject
end

Instance Method Details

#can?(user, action, overridden_subject = nil) ⇒ Boolean

Returns:

  • (Boolean)

16
17
18
# File 'lib/gitlab/view/presenter/base.rb', line 16

def can?(user, action, overridden_subject = nil)
  super(user, action, overridden_subject || subject)
end

#declarative_policy_delegateObject

delegate all #can? queries to the subject


21
22
23
# File 'lib/gitlab/view/presenter/base.rb', line 21

def declarative_policy_delegate
  subject
end

#is_a?(type) ⇒ Boolean

Returns:

  • (Boolean)

33
34
35
# File 'lib/gitlab/view/presenter/base.rb', line 33

def is_a?(type)
  super || subject.is_a?(type)
end

#present(**attributes) ⇒ Object


25
26
27
# File 'lib/gitlab/view/presenter/base.rb', line 25

def present(**attributes)
  self
end

#url_builderObject


29
30
31
# File 'lib/gitlab/view/presenter/base.rb', line 29

def url_builder
  Gitlab::UrlBuilder.instance
end

#web_pathObject


41
42
43
# File 'lib/gitlab/view/presenter/base.rb', line 41

def web_path
  url_builder.build(subject, only_path: true)
end

#web_urlObject


37
38
39
# File 'lib/gitlab/view/presenter/base.rb', line 37

def web_url
  url_builder.build(subject)
end