I'm new to Ruby, but some things have changed since this question was asked: https://blog.saeloun.com/2019/10/07/ruby-2-7-keyword-arguments-redesign/. For a constructor like this:
def initialize(channel_id:, token:)
@channel_id = channel_id
@bot_token = token
end
...I need this kind of code to populate a new instance from entries in config.yml
:
case entry['type']
when 'my'
# Invalid keys will cause an exception.
args = destination.transform_keys(&:to_sym)
args.delete(:type)
slack = MyClass.new(**args)