Class: Braid::T::Struct

Inherits:
Object
  • Object
show all
Defined in:
lib/braid/sorbet/fake_runtime.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**kwargs) ⇒ Struct

Returns a new instance of Struct.



78
79
80
81
82
83
84
85
# File 'lib/braid/sorbet/fake_runtime.rb', line 78

def initialize(**kwargs)
  # The fake runtime isn't obliged to validate the property names or
  # types.
  #
  # Note: If the caller passed a hash of keyword arguments, Ruby will copy
  # it, so we don't need to copy `kwargs` again here to avoid aliasing.
  @attrs = kwargs
end

Class Method Details

.prop(prop_name, prop_type) ⇒ Object



87
88
89
90
91
92
93
94
# File 'lib/braid/sorbet/fake_runtime.rb', line 87

def self.prop(prop_name, prop_type)
  define_method(prop_name) {
    @attrs[prop_name]
  }
  define_method(:"#{prop_name}=") { |new_value|
    @attrs[prop_name] = new_value
  }
end