Module: Gitlab::Patch::Prependable
- Defined in:
- lib/gitlab/patch/prependable.rb
Defined Under Namespace
Classes: MultiplePrependedBlocks
Instance Method Summary
collapse
Instance Method Details
#class_methods ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/gitlab/patch/prependable.rb', line 45
def class_methods
super
class_methods_module = const_get(:ClassMethods, false)
if instance_variable_defined?(:@_prepended_class_methods)
class_methods_module.prepend @_prepended_class_methods
end
extend class_methods_module if Gitlab::Environment.static_verification?
end
|
#prepend_features(base) ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/gitlab/patch/prependable.rb', line 22
def prepend_features(base)
return false if prepended?(base)
Module.instance_method(:prepend_features).bind_call(self, base)
if const_defined?(:ClassMethods)
klass_methods = const_get(:ClassMethods, false)
base.singleton_class.prepend klass_methods
base.instance_variable_set(:@_prepended_class_methods, klass_methods)
end
if instance_variable_defined?(:@_prepended_block)
base.class_eval(&@_prepended_block)
end
true
end
|
#prepended(base = nil, &block) ⇒ Object
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/gitlab/patch/prependable.rb', line 58
def prepended(base = nil, &block)
if base.nil?
raise MultiplePrependedBlocks if
instance_variable_defined?(:@_prepended_block)
@_prepended_block = block
else
super
end
end
|
#prepended?(base) ⇒ Boolean
69
70
71
72
73
|
# File 'lib/gitlab/patch/prependable.rb', line 69
def prepended?(base)
index = base.ancestors.index(base)
base.ancestors[0...index].index(self)
end
|