I found myself repeating something like this in all projects that I'm
working on:
class MyStruct < Struct.new(:x, :y)
# Allows initialization via keyword arguments (Ruby
# only supports positional arguments by default)
def initialize(**kwargs)
super(*members.map{|k| kwargs[k] })
end
end
Thought it'd be worth extracting into a gem:
Regards,
Paul