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

Instance Method Details

#eagerly_define_lazy_methods!Object



117
118
119
120
121
122
123
124
125
126
# File 'lib/types/props/has_lazily_specialized_methods.rb', line 117

def eagerly_define_lazy_methods!
  return if lazily_defined_methods.empty?

  source = "# frozen_string_literal: true\n" + lazily_defined_methods.values.map(&:call).map(&:to_s).join("\n\n")

  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



129
130
131
132
133
134
135
136
137
# File 'lib/types/props/has_lazily_specialized_methods.rb', line 129

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