Class: T::Props::Private::ApplyFixedDefault
- Inherits:
-
ApplyDefault
- Object
- ApplyDefault
- T::Props::Private::ApplyFixedDefault
- Defined in:
- lib/types/props/private/apply_default.rb
Direct Known Subclasses
Constant Summary
Constants inherited from ApplyDefault
T::Props::Private::ApplyDefault::NO_CLONE_TYPES
Constants included from Helpers
Instance Attribute Summary
Attributes inherited from ApplyDefault
Instance Method Summary collapse
-
#initialize(default, accessor_key, setter_proc) ⇒ ApplyFixedDefault
constructor
A new instance of ApplyFixedDefault.
- #set_default(instance) ⇒ Object
Methods inherited from ApplyDefault
Methods included from Sig
Methods included from Helpers
#abstract!, #final!, #interface!, #mixes_in_class_methods, #requires_ancestor, #sealed!
Constructor Details
#initialize(default, accessor_key, setter_proc) ⇒ ApplyFixedDefault
Returns a new instance of ApplyFixedDefault.
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/types/props/private/apply_default.rb', line 71 def initialize(default, accessor_key, setter_proc) # FIXME: Ideally we'd check here that the default is actually a valid # value for this field, but existing code relies on the fact that we don't. # # :( # # setter_proc.call(default) @default = T.let(default, BasicObject) super(accessor_key, setter_proc) end |
Instance Method Details
#set_default(instance) ⇒ Object
84 85 86 |
# File 'lib/types/props/private/apply_default.rb', line 84 def set_default(instance) instance.instance_variable_set(@accessor_key, default) end |