module T::Props::HasLazilySpecializedMethods

Helper for generating methods that replace themselves with a specialized version on first use. The main use case is when we want to generate a method using the full set of props on a class; we can't do that during prop definition because we have no way of knowing whether we are defining the last prop.

See go/M8yrvzX2 (Stripe-internal) for discussion of security considerations. In outline, while `class_eval` is a bit scary, we believe that as long as all inputs are defined in version control (and this is enforced by calling `disable_lazy_evaluation!` appropriately), risk isn't significantly higher than with build-time codegen.

Public Class Methods

disable_lazy_evaluation!() click to toggle source
# File lib/types/props/has_lazily_specialized_methods.rb, line 34
def self.disable_lazy_evaluation!
  @lazy_evaluation_disabled ||= true
end
lazy_evaluation_enabled?() click to toggle source
# File lib/types/props/has_lazily_specialized_methods.rb, line 39
def self.lazy_evaluation_enabled?
  !@lazy_evaluation_disabled
end