Skip to content

Instantly share code, notes, and snippets.

@indigoviolet
Created December 23, 2017 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save indigoviolet/4b315aee733e1753a2fb35f21b8bfa76 to your computer and use it in GitHub Desktop.
Save indigoviolet/4b315aee733e1753a2fb35f21b8bfa76 to your computer and use it in GitHub Desktop.
fin blog embed
class ImmutabilityError < StandardError; end
Contract Hash => DescendantOf[KeywordStruct]
def self.define(**args)
KeywordStruct.new(*args.keys) do
include C
Contract KeywordArgs[**args] => Any
def initialize(**params)
super
end
args.keys.each do |k|
define_method "#{k}=" do |_val|
raise ImmutabilityError.new
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment