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

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

Instance Attribute Summary

Attributes included from Base

#subject

Instance Method Summary collapse

Methods included from Base

#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.


9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/gitlab/view/presenter/delegated.rb', line 9

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

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

    define_singleton_method(key) { value }
  end

  super(subject)
end