Module: T::Props::HasLazilySpecializedMethods
- Extended by:
- Sig
- Defined in:
- lib/types/props/has_lazily_specialized_methods.rb
Overview
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.
Defined Under Namespace
Modules: DecoratorMethods Classes: SourceEvaluationDisabled
Class Method Summary collapse
Methods included from Sig
Class Method Details
.disable_lazy_evaluation! ⇒ Object
34 35 36 |
# File 'lib/types/props/has_lazily_specialized_methods.rb', line 34 def self.disable_lazy_evaluation! @lazy_evaluation_disabled ||= true end |
.lazy_evaluation_enabled? ⇒ Boolean
39 40 41 |
# File 'lib/types/props/has_lazily_specialized_methods.rb', line 39 def self.lazy_evaluation_enabled? !defined?(@lazy_evaluation_disabled) || !@lazy_evaluation_disabled end |