module T::Props::HasLazilySpecializedMethods::DecoratorMethods

Public Instance Methods

eagerly_define_lazy_methods!() click to toggle source
# File lib/types/props/has_lazily_specialized_methods.rb, line 112
def eagerly_define_lazy_methods!
  return if lazily_defined_methods.empty?

  source = 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!() click to toggle source
# File lib/types/props/has_lazily_specialized_methods.rb, line 124
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

Private Instance Methods

enqueue_lazy_method_definition!(name, &blk) click to toggle source
# File lib/types/props/has_lazily_specialized_methods.rb, line 82
        def enqueue_lazy_method_definition!(name, &blk)
  lazily_defined_methods[name] = blk

  cls = decorated_class
  cls.send(:define_method, name) do |*args|
    self.class.decorator.send(:eval_lazily_defined_method!, name)
    send(name, *args)
  end
  if cls.respond_to?(:ruby2_keywords, true)
    cls.send(:ruby2_keywords, name)
  end
  cls.send(:private, name)
end
enqueue_lazy_vm_method_definition!(name, &blk) click to toggle source
# File lib/types/props/has_lazily_specialized_methods.rb, line 97
        def enqueue_lazy_vm_method_definition!(name, &blk)
  lazily_defined_vm_methods[name] = blk

  cls = decorated_class
  cls.send(:define_method, name) do |*args|
    self.class.decorator.send(:eval_lazily_defined_vm_method!, name)
    send(name, *args)
  end
  if cls.respond_to?(:ruby2_keywords, true)
    cls.send(:ruby2_keywords, name)
  end
  cls.send(:private, name)
end
eval_lazily_defined_method!(name) click to toggle source
# File lib/types/props/has_lazily_specialized_methods.rb, line 57
        def eval_lazily_defined_method!(name)
  if !HasLazilySpecializedMethods.lazy_evaluation_enabled?
    raise SourceEvaluationDisabled.new
  end

  source = lazily_defined_methods.fetch(name).call

  cls = decorated_class
  cls.class_eval(source.to_s)
  cls.send(:private, name)
end
eval_lazily_defined_vm_method!(name) click to toggle source
# File lib/types/props/has_lazily_specialized_methods.rb, line 70
        def eval_lazily_defined_vm_method!(name)
  if !HasLazilySpecializedMethods.lazy_evaluation_enabled?
    raise SourceEvaluationDisabled.new
  end

  lazily_defined_vm_methods.fetch(name).call

  cls = decorated_class
  cls.send(:private, name)
end
lazily_defined_methods() click to toggle source
# File lib/types/props/has_lazily_specialized_methods.rb, line 47
        def lazily_defined_methods
  @lazily_defined_methods ||= {}
end
lazily_defined_vm_methods() click to toggle source
# File lib/types/props/has_lazily_specialized_methods.rb, line 52
        def lazily_defined_vm_methods
  @lazily_defined_vm_methods ||= {}
end