Runtime assertions for Ruby literal.fun
ruby
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

Hide literal value type attribute

+3 -2
+1 -1
lib/literal.rb
··· 19 19 value_class = Class.new(Literal::Value) 20 20 21 21 type = Literal::Types._Constraint(*args, **kwargs) 22 - value_class.define_method(:type) { type } 22 + value_class.define_method(:__type__) { type } 23 23 24 24 if subtype?(type, Integer) 25 25 value_class.alias_method :to_i, :value
+2 -1
lib/literal/value.rb
··· 9 9 new(value) 10 10 end 11 11 12 + # Takes a list of method names and delegates them to the underlying value. 12 13 def self.delegate(*methods) 13 14 methods.each do |method_name| 14 15 class_eval(<<~RUBY, __FILE__, __LINE__ + 1) ··· 22 23 end 23 24 24 25 def initialize(value) 25 - Literal.check(expected: type, actual: value) 26 + Literal.check(expected: __type__, actual: value) 26 27 @value = value 27 28 freeze 28 29 end