Class: Gitlab::View::Presenter::Delegated

Inherits:
SimpleDelegator
  • Object
show all
Extended by:
Utils::DelegatorOverride
Includes:
Base
Defined in:
lib/gitlab/view/presenter/delegated.rb

Instance Method Summary collapse

Methods included from Utils::DelegatorOverride

delegator_override, delegator_override_with, delegator_target, validator, validators, verify!

Methods included from Base

#__subject__, #can?, #declarative_policy_delegate, #is_a?, #present, #url_builder, #web_path, #web_url

Methods included from Allowable

#can?

Methods included from Routing

add_helpers, includes_helpers, redirect_legacy_paths, url_helpers

Constructor Details

#initialize(subject, **attributes) ⇒ Delegated

Returns a new instance of Delegated.


20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/gitlab/view/presenter/delegated.rb', line 20

def initialize(subject, **attributes)
  @subject = subject

  attributes.each do |key, value|
    if subject.respond_to?(key)
      raise CannotOverrideMethodError, "#{subject} already respond to #{key}!"
    end

    define_singleton_method(key) { value }
  end

  super(subject)
end