16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/typelizer/delegate_tracker.rb', line 16
def delegate(*methods, to:, allow_nil: nil, prefix: nil, **)
super.tap do
next unless is_a?(Class) && defined?(ActiveRecord::Base) && !ActiveRecord.autoload?(:Base) && self < ActiveRecord::Base
method_prefix = if prefix == true
"#{to}_"
else
prefix ? "#{prefix}_" : ""
end
methods.each do |m|
(DelegateTracker.registry[self] ||= {})[:"#{method_prefix}#{m}"] = {to: to, allow_nil: !!allow_nil, original: m.to_sym}
end
end
end
|