Method: T::Enum#initialize
- Defined in:
- lib/sorbet/eraser/t/enum.rb
#initialize(serialized_val = nil) ⇒ Enum
Private implementation ##
146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/sorbet/eraser/t/enum.rb', line 146 def initialize(serialized_val=nil) raise 'T::Enum is abstract' if self.class == T::Enum if !self.class.started_initializing? raise "Must instantiate all enum values of #{self.class} inside 'enums do'." end if self.class.fully_initialized? raise "Cannot instantiate a new enum value of #{self.class} after it has been initialized." end serialized_val = serialized_val.frozen? ? serialized_val : serialized_val.dup.freeze @serialized_val = serialized_val @const_name = nil self.class._register_instance(self) end |