···1919 value_class = Class.new(Literal::Value)
20202121 type = Literal::Types._Constraint(*args, **kwargs)
2222- value_class.define_method(:type) { type }
2222+ value_class.define_method(:__type__) { type }
23232424 if subtype?(type, Integer)
2525 value_class.alias_method :to_i, :value
+2-1
lib/literal/value.rb
···99 new(value)
1010 end
11111212+ # Takes a list of method names and delegates them to the underlying value.
1213 def self.delegate(*methods)
1314 methods.each do |method_name|
1415 class_eval(<<~RUBY, __FILE__, __LINE__ + 1)
···2223 end
23242425 def initialize(value)
2525- Literal.check(expected: type, actual: value)
2626+ Literal.check(expected: __type__, actual: value)
2627 @value = value
2728 freeze
2829 end