Module: T::Props::HasLazilySpecializedMethods::DecoratorMethods

Extended by:
Sig
Included in:
Serializable::DecoratorMethods
Defined in:
lib/types/props/has_lazily_specialized_methods.rb

Instance Method Summary collapse

Methods included from Sig

sig

Methods included from T::Private::Methods::SingletonMethodHooks

#singleton_method_added

Methods included from T::Private::Methods::MethodHooks

#method_added

Instance Method Details

#eagerly_define_lazy_methods!Object



151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/types/props/has_lazily_specialized_methods.rb', line 151

def eagerly_define_lazy_methods!
  return if lazily_defined_methods.empty?

  # rubocop:disable Style/StringConcatenation
  source = "# frozen_string_literal: true\n" + lazily_defined_methods.values.map(&:call).map(&:to_s).join("\n\n")
  # rubocop:enable Style/StringConcatenation

  cls = decorated_class
  cls.class_eval(source)
  lazily_defined_methods.each_key { |name| cls.send(:private, name) }
  lazily_defined_methods.clear
end

#eagerly_define_lazy_vm_methods!Object



165
166
167
168
169
170
171
172
173
# File 'lib/types/props/has_lazily_specialized_methods.rb', line 165

def eagerly_define_lazy_vm_methods!
  return if lazily_defined_vm_methods.empty?

  lazily_defined_vm_methods.values.map(&:call)

  cls = decorated_class
  lazily_defined_vm_methods.each_key { |name| cls.send(:private, name) }
  lazily_defined_vm_methods.clear
end